test(libc): keep exception runtime assertions enabled in Release #1129
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1129"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by AaravMehta-07 on 2026-10-07T13:20:13Z.
What
Keep the existing exception-runtime assertions active in Release builds by undefining
NDEBUGbefore<cassert>in the test translation unit. No assertions, runtime code, CMake flags or other tests change.CI configures
Release, and GCC compiles this test with-O3 -DNDEBUG. That removes all 57assertexpressions. It also removes thepthread_create,pthread_joinandwaitpidcalls inside them, so the test reports success without running its four exception worker threads or checking its termination/forced-unwind child statuses.Tested
Linux x86-64 under Ubuntu 26.04/WSL2 (kernel 6.6.87.2), GCC 15.2.0, CMake 4.2.3, Ninja 1.13.2, Python 3.14.4. Vulkan execution tests use Mesa lavapipe.
straceconfirms zero worker threads and zero child waits.straceconfirms four worker threads and three child waits; all existing checks pass. Clean Releaseexception_runtimepasses ten consecutive runs.-O3 -DNDEBUGflags: change the first destructor-count expectation from 1 to 0 in temporary test copies. Without this fix the wrong expectation passes (exit 0); with it the test aborts at that assertion (SIGABRT). The submitted assertions are unchanged.libstarget pass. After updating toe79c971f, full CTest runs 396 tests: 373 pass, 22 skip and one unrelated local failure.guest_errorsalso fails on unmodifiede79c971f, atGuestErrors.cpp:30: it expects errno 13 after creating/joining a host thread, but errno is 22 here. A standalone nativestd::threadprogram with no AnyPS5 code reproduces 13 -> 22. This is outside this test-only change. Skips are unavailable write tracking and lavapipe subgroup capabilities; they are not counted as executed passes.-O0 -g) and RelWithDebInfo (-O2 -g -DNDEBUG) test-source builds both pass against the Release runtime.The FFmpeg directory reuses only the upstream dependency package, not compiled project objects. Windows does not register this Unix-only test. macOS and commercial titles were not tested; no compatibility improvement is claimed.
AI assistance was used during investigation and implementation. The one-line diff was reviewed and validated with the existing tests and independent tracing/mutation checks.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (none changed).mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T13:55:07Z.
Confirmed independently on Linux (CachyOS, GCC, Release), at object level rather than from the source alone.
CI configures
Release(-DCMAKE_BUILD_TYPE=Release,.github/workflows/build.yml:18), so GCC passes-DNDEBUGand the TU's asserts are removed at compile time. Built the registered target onmain:Only
forksurvives. The consequences are a little wider than "the assertions do not run":main(NDEBUG)CheckThreadspthread_create/pthread_joinare the assert operands, so no thread is created —ThreadTestnever runsCheckTerminate,CheckForcedUnwindfork()is a bare statement and survives, butwaitpid(child, …)is inside an assert, so both children are forked and never reaped; theWEXITSTATUSchecks are goneSo on
mainthe Linux ctest test (exception_runtime, #26) reports success while exercising no threads and leaking two unreaped children per run.With your one line applied, all three reappear:
The mechanism is exactly as you describe, and the fix restores the coverage the test was written for. One note, not a request: the side-effecting calls live inside
assert, which is what makes the semantics depend on NDEBUG; moving thepthread_create/waitpidcalls out and asserting on their results would make the test robust to the build type by construction.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T02:48:42Z.
Review: COMMENTED
Built it and demonstrated the change is not cosmetic — this one restores a test that could not fail.
The proof, both ways. Build type here is
CMAKE_BUILD_TYPE=Release, soNDEBUGis defined andassertexpands away. I added a deliberately false assertion to the test and built it twice:So without the change the file's 54
assert(calls were compiled out entirely:exception_runtime_testspassed in a Release build no matter what the exception runtime did. With it, the assertion fires. That is the whole difference between a test and a green tick, and it is why this is worth more than the two lines it touches.The placement is the part that has to be right, and it is.
#undef NDEBUGsits before#include <cassert>. After the include it would have had no effect, because<cassert>bakesassert's definition at inclusion time — so the two lines are in the only order that works.After the change the test passes on its merits:
54 live assertions against the exception runtime, all satisfied. That is a much stronger statement than the same command produced before.
I checked whether other tests share the problem, and none does. Eight files matched a naive
assert(search, but a precise one — runtimeassert(rather thanstatic_assert(— leaves this file as the only one:So there is no follow-up list to hand anyone, which is the answer I wanted rather than a list of eight more files.
Nothing to change. A test that cannot fail is worse than a missing test, because it reports coverage that is not there.
This is a comment, not an approval — I have no merge rights here.
Written with AI assistance.