11,940 karma · joined Jun 29, 2012 (14y ago) · 8,736 submissions
comment 3mo ago · link · parent
For variadic functions, if you use `va_start()`/`va_arg()`/`va_end()` to consume all the arguments, and leave no `va_list` alive, then the compiler can correctly generate a tail call from such functions.
comment 3mo ago · link · parent
> The caller could see the declaration int f();, the actual call could have n>0 arguments, and the actual function could have m≤n parameters.
Certainly if `f()` were `int f(void);` then that wouldn't be the case. But even for `int f();` C17 6.5.2.2p6 says that "If the number of arguments does not equal the number of parameters, the behavior is undefined." Near as I can tell that was made UB in C89. So TFA is a) right about K&R C, b) just wrong for pretty much all post-K&R C. C23 makes `int f();` be the same as `int f(void);`.
That calling a non-variadic function with more / fewer arguments than expected by its definition is UB is enough to make TCO possible for that function's body.
The point about K&R C is well taken though: to turn a tail call into a jump, the caller needs to know how much to pop off the stack.
For variadic if you `va_start()`, `va_arg()` as needed, then `va_end()` with no `va_copy()` left alive then you can still tail-call out correctly, otherwise you can't.
For non-variadic functions post K&R C TCO should always be possible and not UB, provided you're not triggering UB to begin with by using the incorrect number of arguments.
comment 5mo ago · link · parent
> The fix is pretty straightforward: treat comment content as untrusted data, not as potential instructions. Comments should be passed to the model with clear role boundaries that prevent them from being interpreted as system-level directives.
If only prompt injection were that easy to defeat! Then YouTube would have done it already, I'm sure, among many others.
comment 5mo ago · link · parent
Now, in many cases it's super convenient to have 'internal' -integers, UUIDs- entity IDs. If you're building a graph database with an EAV schema, then it's especially convenient, and it might even be the only way since different kinds of entities might have different numbers and kinds of attributes as their unique keys, but you might still need to reference them from an EAV table.
GP's is a very good question and it should not have been downvoted. It's a great question to explore.
comment 5mo ago · link · parent
LLMs only really took off almost entirely under this administration. No one knows quite how to regulate these things. It's not surprising that they would flail a bit. It seems to have been DoD people who did the flailing here, and apart from Hegseth, there might have been others who did the overreacting, possibly before him.
comment 5mo ago · link · parent
comment 5mo ago · link · parent
A better analogy is that continuations are reified function call return addresses, since return addresses come with a frame pointer (explicit or implicit), and therefore are closure-like.
comment 6mo ago · link · parent
The real restrictions are:
- you can't damage the function call frame
of the caller of vfork(), thus you can't
return from it
- you may only call async-signal-safe
functions on the child side of vfork()
That's basically it. Yes, you'll want to call execve(2) or _exit(2) before long, but there is no time limit as to that, it's just that the whole point of calling vfork() is to make it real cheap to spawn a process, which means ultimately calling execve(2), with _exit(2) being what you do if it execve(2) fails (e.g., because ENOENT).There is a ton of vfork()-using code that adheres to these real restrictions and has been working fine for decades. That includes several posix_spawn() implementations, the C shell, etc.
I demand evidence that this part: "the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork()" is remotely true. That evidence must be of the form of bug reports that were accepted and which stand to scrutiny.
I've never found any such evidence. Have you?
Meanwhile I have a proof by existence that vfork() is safe used much more liberally than you say it may be used.
> You can't use local variables, or call any functions other than _exit or execve.
There are other async-signal-safe functions, and they get used routinely by posix_spawn() and other code to do child-side setup before execve(2), including: I/O redirection, process group setup, signal handling changes, etc.
comment 6mo ago · link · parent
I've no idea about that and I won't opine. But every time I see that sort of statement it seems likely motivated by the whole Twitter acquisition. Perhaps that was just a toy or vanity project for him, one he could afford, so even if you think he's running X terribly it might have nothing to do with how he's run or would run any other companies that are not related to social media. In other words, what I read into such statements is "I don't like the politics he's brought to Twitter!", "the board should rein in the guy whose politics I don't like!!". It's like saying Bezos is bad at business because he owns the Washington Post -another vanity project- and you don't like the Post.
Do people not get bored of that sort of take?
Tell me he makes bad business decisions all you want, but in the context of everyone-hates-his-acquisition-of-Twitter I'd like to hear about his other businesses. Tell me something useful, not something political.
And, sure, politics at some point bleeds into business. Maybe Trump is out to get Bezos over Washington Post coverage, or maybe the next Democrat President will go after Musk for his politics. It's possible that X will eventually cost him dearly and personally, and it's a solid argument for these billionaires and trillionaires to stay out of politics. Or maybe it's a good argument for them to stay in because maybe by demonstrating electoral influence and power they can make the POTUS-of-the-day fear them enough to not go after them too hard. But if you made any such argument it still wouldn't say tell me anything about the rest of these billionaires' businesses.
comment 6mo ago · link · parent
comment 6mo ago · link · parent
> No, it was done that way so that you could launch a program that was too big to fit in memory with the parent program.
Ironically vfork() is even better in this regard. I wish Unix had only ever had vfork().