Repository navigation
vms-599: DEC C exit()/__posix_exit() record the VMS completion status (oracle-grounded) - #1839
Merged
Merged
Conversation
…atus OVMX's DECC$SHR exit() was musl's. It ran the atexit handlers, flushed stdio and exit_group()ed a POSIX code, but nothing recorded the status. DCL then read the image's exit(1), which is a success on VMS, as "%DCL-E-ABORT ... exited with error status %X00000001". That was the wall on #1810: the GCC port's ar ends with exit(system(...)). Measured on OpenVMS Alpha V8.4 with MACRO-32 probes that call the C RTL directly (tests/lab/captures/decc-exit-alpha-20261021): - DECC$EXIT maps 0 to %X00000001 and passes every other value through. - DECC$__POSIX_EXIT keeps n&255. It maps 0 to %X00000001, 1 to %X1035A00A, and any other n to %X0035A001+(n<<3). What changed: - crtl_process.c: decc$exit is rebound to ovmx_crtl_exit, and decc$__posix_exit (ovmx_crtl_posix_exit) is a new tail universal. Both record the status and then run musl's exit. - crtl_rms_fd.c: the system-call hook ends the image with SYS$EXIT of that status at the final exit_group, after the handlers and the stdio flush. - build-musl.sh: <stdlib.h> follows DEC C. _POSIX_EXIT makes exit __posix_exit, which is what the GCC port's xm-vms.h asks for. Otherwise EXIT_FAILURE is 2. Test: the crtl-fd gate runs the image as a foreign command, through 11 exit and __posix_exit cases, and checks each $STATUS against the oracle. It also checks that an unflushed line is printed. Three new selftest negative controls cover musl's exit, a raw __posix_exit and a skipped flush. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
baron-3dl
enabled auto-merge
October 21, 2026 17:38
…int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ec-vms The crtl-fd gate's new check found this on the qemu-system-alpha boot: a line printed without a newline and then exit()ed never reached the console. Generic musl exit.c reaches __funcs_on_exit and __stdio_exit through local weak aliases of a no-op. The alpha-dec-vms back end binds same-TU calls to those aliases section-relatively (the vms-032 lite_malloc case), so the strong definitions in atexit.c and __stdio_exit.c never ran. An arch override (src/exit/alpha-dec-vms/exit.c) now calls both by name. A build-time gate in build-musl.sh fails if exit.o defines either symbol or does not reference it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(musl-internal headers), like lite_malloc.c and _Fork.c Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ec-vms The exit() override ran __stdio_exit, but the crtl-fd gate's unflushed line was still lost. musl's __stdio_exit.c reaches the three standard FILEs through weak aliases of a local NULL. The back end self-binds those aliases, so the flush saw no FILE. This adds an arch override that names __stdin_used, __stdout_used and __stderr_used, and extends build-musl.sh's nm gate to check it. Co-Authored-By: Claude Opus 5.5 <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.
Wall (blocks #1810). The GCC port's `ar` ends with `exit(system(...))`. On VMS, `exit(1)` is a success. OVMX's DECC$SHR `exit()` was musl's: it ran atexit, flushed stdio and `exit_group()`ed a POSIX code, with nothing recorded. DCL therefore reported `%DCL-E-ABORT, image SYS$SYSTEM:AR.EXE exited with error status %X00000001` even though LIBRARY had built the archive.
Oracle. Measured today on OpenVMS Alpha V8.4 with MACRO-32 probes calling the CRTL directly. The capture is in `tests/lab/captures/decc-exit-alpha-20261021/`.
Fix.
Test. The crtl-fd gate now runs 11 exit and `__posix_exit` cases as foreign commands. Each `$STATUS` must equal the oracle value, and an unflushed line must appear. Three new selftest negatives check that the assertion fails on musl's exit, a raw `__posix_exit`, and a skipped flush. All selftests passed locally.
Not in this PR. `decc$_exit` is unchanged. Neither entry point is added to `DECC$SHR_EV56.vec` for natively-linked images.
🤖 Generated with Claude Code