Repository navigation
test(libc): cover the standard exception classes and throw helpers - #9773
DavidSamir wants to merge 1 commit into
Conversation
No test constructed, copied, assigned or destroyed the standard exception classes libc exports, or called their throw helpers. A new guest_standard_exception_classes test checks, for exception, bad_alloc, bad_array_new_length, bad_cast, bad_typeid and bad_function_call, the type name and base, the vtable, both constructors, what and the three destructors. For logic_error, domain_error, invalid_argument, length_error, out_of_range and runtime_error it also checks that what returns the constructor's message, that copies share it and that assignment replaces it. bad_weak_ptr's what and destructors and ten throw helpers are run too.
MarcZX10
left a comment
There was a problem hiding this comment.
The new test checks type records and base relationships, vtable address points, constructors/destructors (including deleting destructors), message ownership and assignment, and all ten throw helpers. I compared its expected object/vtable layout and behavior with StandardExceptions.cpp; the assertions match the implementation. The reported negative control for assignment adds useful red/green evidence.
Hosted register-context tests pass on Ubuntu and macOS Intel in Debug and Release; conventions, eligibility, relinker, ASan and write-watch checks also pass. Linux/Windows product jobs are skipped by policy. The current-main commits since the PR base do not touch StandardExceptions.cpp or this CMake section; merge-tree and diff-check are clean. I did not rerun CTest locally because there is no configured build and less than 1 GB free on disk.
#9775 also adds a separate CMake test registration in this block; the pairwise merge is clean and the registrations do not overlap semantically. No implementation duplicate was found.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
The exact head f934c4b2c53aae56b3abebf933c32c27df08ba94 has a clean merge tree with current main (11f976b27c16ed91633f00039dba5dfd97dd7cc1); conventions and diff-check pass. The test covers the standard exception hierarchy, vtable slots, constructors/destructors, assignment, and throw helpers. The author reports Windows focused and exception-suite results; hosted register-context/relinker checks pass, while product Linux/Windows jobs are skipped. This branch is based on 8b3e39832a, 32 commits behind current main; please rebase and rerun guest_standard_exception_classes before merge. I did not rerun locally.
|
@DavidSamir The test-local exception-object declarations differ from the public types, for example |
|
Tested head
AI-assisted: yes (Claude Code); results above were run on this machine. |
THEMANnt
left a comment
There was a problem hiding this comment.
Re-reviewed f934c4b2c53aae56b3abebf933c32c27df08ba94. Approve; the earlier validation blocker is resolved.
The missing native execution step is complete. Reviewed coverage exercises the standard exception type/vtable records, plain and message-object construction/destruction, message ownership/copies/assignment and the ten throw helpers. No actionable findings.
Validation: Compiled the complete exact GuestStandardExceptionClasses.cpp with the pinned exception runtime through its actual combined translation unit, src/exception/Exports.cpp, using project Windows unwind settings and section conversion. This includes Runtime, TypeInfo, StandardExceptions, Unwind and Personality source in their intended order. The complete test executable returns 0, including all throw/catch assertions.
Scope: Existing libc linkage supplies ancillary symbols; this is not a rebuild of every libc source or all exception tests. The earlier standalone StandardExceptions.cpp compilation failures were reviewer-harness errors caused by bypassing Exports.cpp, not defects introduced by this test. No application/game run.
What
Line coverage of libc and libkernel over the CPU-side test suite (gcov, Windows) showed about 110 exports in
exception/StandardExceptions.cppthat no test ran. They are the constructors, destructors,whatand assignment of the standard exception classes, plus the throw helpers.How:
tests/GuestStandardExceptionClasses.cpp, registered asguest_standard_exception_classesnext toguest_bad_optional_access(it follows the same pattern):exception,bad_alloc,bad_array_new_length,bad_cast,bad_typeidandbad_function_call:exception,bad_allocforbad_array_new_length, otherwiseexception);whatslot;C1EvandC2Evinstall the vtable, andwhat()is non-empty and matches the vtable'swhat;D1EvandD2Evrun, andD0Evdeletes amalloced object.logic_error,domain_error,invalid_argument,length_error,out_of_rangeandruntime_error:logic_errororexception);what()returns the constructor's message, copied, so changing the caller's buffer afterwards doesn't affect it;bad_weak_ptr(no exported constructor): its type,whatand destructors._Xbad_alloc,_Xrange_error,_Xlength_error,_Xinvalid_argument,_Throw_bad_weak_ptr,_Xbad_function_call,__throw_bad_variant_access,__cxa_bad_cast,__cxa_bad_typeidand__cxa_throw_bad_array_new_length.what()text for the classes without a message is checked only for being non-empty; the console's exact strings are not pinned.Tested
bad_*tests.Assignkeeping the old message, the test fails at the assignment check. Restored, it passes.tools/check_conventions.pypasses.Overlap (
tools/pr_overlap.py --branchplusgit merge-tree):libc/CMakeLists.txt;git merge-treeadds no conflict hunk with any of them.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)