Skip to content

Conversation

@swaroop-sridhar
Copy link
Contributor

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 kParseStopWhenDoneFlag indicates 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 a stringstream), 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 kParseStopWhenDoneFlag on Windows, but not on Unix.
This caused kParseErrorDocumentRootNotSingular failure on Unix when parsing json files from single-file bundles.

This change fixes this problem by passing kParseStopWhenDoneFlag on all platforms.
This also makes the host behavior consistent across platforms.

Master Branch

PR: #35073
Commit: 342ed3c

Risk

Very Low

…hitectures (dotnet#35073)

RapidJson's `kParseStopWhenDoneFlag` indicates 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 a `stringstream`), 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 `kParseStopWhenDoneFlag` on Windows, but not on Unix.
This caused `kParseErrorDocumentRootNotSingular` failure on Unix when parsing json files from single-file bundles.

This change fixes this problem by passing `kParseStopWhenDoneFlag` on all platforms.
This also makes the host behavior consistent across platforms.
@ghost
Copy link

ghost commented Apr 30, 2020

Tagging subscribers to this area: @vitek-karas, @swaroop-sridhar
Notify danmosemsft if you want to be subscribed.

@swaroop-sridhar
Copy link
Contributor Author

Closing this PR, since reverting chante #34274 was preferred instead.
#35679

@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants