fix(codegen): null-terminate untyped variadic argument lists - #1887
Open
ghaith wants to merge 2 commits into
Open
fix(codegen): null-terminate untyped variadic argument lists#1887ghaith wants to merge 2 commits into
ghaith wants to merge 2 commits into
Conversation
Problem: A call to an untyped variadic (`args : ...`) passes only the
arguments the caller wrote. A C callee that walks the list until a
terminator cannot find its end and reads past the arguments, which
segfaults, most visibly when the call carries no variadic argument at all.
Solution: Append a null pointer to every untyped variadic call.
Format-directed and count-directed callees read only the arguments they
expect and never see it, and a terminator written by the caller still ends
the list first. Sized (`{sized} T...`) and typed (`T...`) variadics keep
their exact argument list, because both have a callee signature that an
added argument would break.
Refs: PRG-4282
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Build Artifacts🐧 Linux
From workflow run 🪟 Windows
From workflow run |
Problem: The variadic suite calls only C functions that declare a named parameter and read their arguments with the two-argument `va_start`, so it says nothing about the forms C23 allows. Solution: Add a second lane that calls variadic functions with no named parameter at all, reading their arguments with the single-argument `va_start`. The lane probes the compiler for `-std=c23` or `-std=c2x` and reports itself unsupported when neither is accepted. Refs: PRG-4282 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: A call to an untyped variadic (
args : ...) passes only the arguments the caller wrote. A C callee that walks the argument list until a terminator cannot find its end, so it reads past the arguments and segfaults. A call that carries no variadic argument at all crashes on its first read.Solution: Append a null pointer to every untyped variadic call. Format-directed and count-directed callees read only the arguments they expect and never see it, and a terminator written by the caller still ends the list first. Sized (
{sized} T...) and typed (T...) variadics keep their exact argument list, because both have a callee signature that an extra argument would break.Refs: PRG-4282
🤖 Generated with Claude Code