[release/5.0-preview4] Single-File: Fix a json parsing issue #35656
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.
Customer Scenario
Single File apps fail to run on some Linux systems
Problem
Single-file apps now process json config files directly from bundle (#34274).
When parsing json files from memory-mapped files, RapidJson in-situ parsing complains about bytes mapped beyond the end of the file, assuming that they represent content beyond the root element.
Solution
Ask RapidJaon to stop parsing at the end of the root element, similar to Windows.
Details
RapidJson's
kParseStopWhenDoneFlagindicates that parsing should stop once the root element is parsed, and should not throw an error for any further content.This flag is useful when the input stream doesn't always have a null-terminator --
ex: an input
bytestream(rather than astringstream), files embeded within the single file bundle.The limitation of using this flag is that any actual random text after the root element is silently ignored.
Currently, RapidJson is invoked with
kParseStopWhenDoneFlagon Windows, but not on Unix.This caused
kParseErrorDocumentRootNotSingularfailure on Unix when parsing json files from single-file bundles.This change fixes this problem by passing
kParseStopWhenDoneFlagon all platforms.This also makes the host behavior consistent across platforms.
Master Branch
PR: #35073
Commit: 342ed3c
Risk
Very Low