Skip to content

fix(codegen): null-terminate untyped variadic argument lists - #1887

Open
ghaith wants to merge 2 commits into
masterfrom
feat/PRG-4282
Open

fix(codegen): null-terminate untyped variadic argument lists#1887
ghaith wants to merge 2 commits into
masterfrom
feat/PRG-4282

Conversation

@ghaith

@ghaith ghaith commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

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

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>
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

Build Artifacts

🐧 Linux

Artifact Link Size
deb-x86_64 Download 38.4 MB
schema Download 0.0 MB
stdlib Download 32.3 MB
plc-x86_64 Download 43.5 MB
deb-aarch64 Download 30.8 MB
plc-aarch64 Download 43.4 MB

From workflow run

🪟 Windows

Artifact Link Size
stdlib.lib Download 4.0 MB
stdlib.dll Download 0.1 MB
plc.exe Download 38.3 MB

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant