Fix allocation failure during JSON destruction - #5239
Conversation
|
I just merged a test which caused a conflict. Sorry, please rebase. |
Signed-off-by: Michael Sam <michaelsam94@users.noreply.github.com>
877084d to
d428f79
Compare
|
Rebased onto current develop (acf076a) and resolved the test conflict by keeping the newly merged #4320 regression and placing the #5135 regression after it.\n\nRe-ran local checks:\n\n- unit-regression2: 9 test cases, 128 assertions passed\n- unit-allocator: 3 test cases, 17 assertions passed\n- single-header smoke compile\n- no-exceptions smoke compile\n- git diff --check |
|
This pull request has been marked as stale because it has had no activity for 30 days. While we won’t close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions! |
This PR fixes #5135 by preventing allocation failures from the temporary destruction stack from escaping
basic_json'snoexceptdestructor.The existing iterative destruction path is kept unchanged for the normal case. It is now wrapped with the library's
JSON_TRY/JSON_CATCHmacros; if growing the heap-allocated stack throws, destruction falls back to the regular array/object cleanup below instead of allowing the exception to cross the destructor boundary and callstd::terminate.A regression test in
unit-regression2.cppinjects a one-shot global allocation failure while destroying a structured JSON value, verifying that the destructor consumes the failing stack allocation path and returns normally.make amalgamate.Local verification:
I could not run the full CMake suite locally because
cmakeis not available on this machine'sPATH.