Skip to content

Fix nullable struct deserialization across buffer boundaries - #135477

Open
eiriktsarpalis wants to merge 1 commit into
mainfrom
eiriktsarpalis-nullable-json-continuation
Open

eiriktsarpalis wants to merge 1 commit into
mainfrom
eiriktsarpalis-nullable-json-continuation

Conversation

@eiriktsarpalis

Copy link
Copy Markdown
Member

Streaming deserialization can throw JsonException for valid JSON when a buffer boundary follows a null member inside a nullable struct. ReadStack.Push() clears IsContinuation when restoring the deepest suspended frame, causing NullableConverter<T> to treat the member token as a null nullable value. Require ObjectState.None before taking that fast path.

Adds boundary sweeps, short-read and buffer-growth checks, and direct PipeReader tests for segmented buffers, one-byte flushes, and truncated input, with reflection and source-generated metadata.

On Windows, all 96 targeted cases per framework passed on net11.0 and net481; reverting the fix produces 48 failures per framework. All six System.Text.Json test projects passed with zero failures and 17 existing skips.

Resolves #110450

Note

This pull request was created with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a057a99f-e202-4c25-a1ee-247c2e9c0a5d
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Text.Json.JsonException thrown when deserializing asynchronously to nullable types

1 participant