Fix allocation failure during JSON destruction#5239
Open
michaelsam94 wants to merge 1 commit into
Open
Conversation
Owner
|
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
Author
|
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 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.
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.