Skip to content

Conversation

@xuhdev
Copy link
Contributor

@xuhdev xuhdev commented Aug 8, 2025

jsoncpp, as a shared library, should not call abort merely because there's an error reading a value.

See https://en.cppreference.com/w/c/program/abort, abort should only be called to abnormally cause the program to exit. Functions inserted by atexit are also not called, meaning that the host program may have not cleaned up resources properly. But here, exceeding stack limit isn't a sign of abnormalty.

exit is not a good substitute either, see the exit-in-shared-library from Debian: https://lintian.debian.org/tags/exit-in-shared-library.html

Fix #1618

In this case, returning false seems like a better idea.

jsoncpp, as a shared library, should not call `abort` merely because there's an error reading a value.

See https://en.cppreference.com/w/c/program/abort, `abort` should only be called to **abnormally** cause the program to exit. Functions inserted by `atexit` are also not called, meaning that the host program may have not cleaned up resources properly. But here, exceeding stack limit isn't a sign of abnormalty.

`exit` is not a good substitute either, see the `exit-in-shared-library` from Debian:
https://lintian.debian.org/tags/exit-in-shared-library.html

Fix open-source-parsers#1618

In this case, returning false seems like a better idea.
@baylesj
Copy link
Contributor

baylesj commented Nov 12, 2025

SGTM, I definitely agree that JsonCpp aborting should happen very infrequently and indicate a major crises, not just bad user input or a large input.

@baylesj baylesj merged commit 30e7528 into open-source-parsers:master Nov 12, 2025
10 checks passed
@xuhdev xuhdev deleted the readvalue branch November 12, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jsoncpp, as a shared library, should not call abort in Reader::readValue()

2 participants