Repository navigation
Conversation
basic_parser::reset() discards the parser state but leaves the handler alone, and into_handler never restored its own state either: * on_document_end sets inner_active_ to false, so once a parser_for has finished a document, every document after reset() fails with error::extra_data; * the nested handlers keep the progress of the value they are in (the string handler's cleared_, the sequence handler's inner_active_, ...), so after a document that stopped in the middle of a value, the next document continues from there: a string is appended to the previous partial string, and a sequence fails with a type error. Re-create the nested handler and reactivate it in on_document_begin.
|
An automated preview of the documentation is available at https://1226.json.prtest2.cppalliance.org/libs/json/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-11-20 14:47:26 UTC |
|
GCOVR code coverage report https://1226.json.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-11-20 15:16:43 UTC |
|
|
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.

A
parser_for<T>cannot be used for another document afterreset():error::extra_data;more = true, or an error), the next document continues from where the previous one stopped: astd::stringtarget gets the new string appended to the old partial one, and a sequence fails with a type error.basic_parser::reset()is documented to discard the current parsing state "to prepare for parsing a new document", and a newparser_forparses the same documents fine.Repro (develop e93b106, clang 21, libc++):
Output on develop:
With this change the first four lines are the same as the last two.
Cause:
basic_parser::reset()resets the parser but not the handler, andinto_handler::on_document_begindoes nothing.into_handler::on_document_endsetsinner_active_tofalse, which then rejects the first event of the next document. The nested handlers keep the progress of the value they are in: the string handler'scleared_is set by the firston_string_partand cleared again byon_string, and a sequence handler'sinner_active_staystrueuntil its array ends, so a document that stops inside a value leaves them in the middle of it.Fix: in
into_handler::on_document_begin, re-create the nested handler (destroy it and construct it again with the same value and parent) and setinner_active_back totrue. Re-creating the handler covers every handler kind (strings, sequences, maps, tuples, variants, optionals, described structs) without adding a reset to each of them.Test:
testParseIntoValueintest/parse_into/common.hppnow reuses itsparser_forafterreset(), once after the complete document and once after a document that stops one character short of the end, and compares the result withvalue_to. On develop this fails in all sevenparse_intotest files; with the change they all pass (built directly with clang 21 and libc++ under ASan and UBSan, no reports).