Skip to content

handle bad/invalid chunks as input more defensively#5671

Merged
anonrig merged 1 commit intomainfrom
yagiz/v8-assert-bad-chunk
Dec 10, 2025
Merged

handle bad/invalid chunks as input more defensively#5671
anonrig merged 1 commit intomainfrom
yagiz/v8-assert-bad-chunk

Conversation

@anonrig
Copy link
Copy Markdown
Member

@anonrig anonrig commented Dec 10, 2025

Fixes #5394

Failing web-platform test can be found at https://github.com/web-platform-tests/wpt/blob/master/encoding/streams/decode-bad-chunks.any.js. It tests for passing invalid chunk into the stream, and prior to this function we didn't throw the correct error, even though we failed. This change ensures that we are WPT compliant.

@anonrig anonrig requested review from a team as code owners December 10, 2025 21:04
@anonrig anonrig requested review from jasnell and npaun December 10, 2025 21:05
@jasnell
Copy link
Copy Markdown
Collaborator

jasnell commented Dec 10, 2025

Can I ask that you expand the PR description a bit more detailing the issue and summarizing the fix.

@anonrig
Copy link
Copy Markdown
Member Author

anonrig commented Dec 10, 2025

Can I ask that you expand the PR description a bit more detailing the issue and summarizing the fix.

Definitely. Just updated the description.

@anonrig anonrig enabled auto-merge (squash) December 10, 2025 21:16
Copy link
Copy Markdown
Collaborator

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the "invalid chunks" here means passing invalid types to input the stream.

@anonrig anonrig changed the title handle bad chunks more defensively handle bad/invalid chunks as input more defensively Dec 10, 2025
comment: 'Failed V8 assert',
// external/v8/src/api/api-inl.h:163; message = v8::internal::ValueHelper::IsEmpty(that) || IsJSArrayBufferView(v8::internal::Tagged<v8::internal::Object>( v8::internal::ValueHelper::ValueAsAddress(that)))
disabledTests: true,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I guess there's a question here to ask about whether we want to rely entirely on the WPT's for these cases or extend our workerd tests to account for these. That's a broader question, of course that doesn't necessarily need to be addressed in these individual PRs. It's worth noting, however, that since we do not have control over the WPT's, changes could in theory be introduced in the tests that change the expectations. We might not catch those. It's exceedingly unlikely so probably not worth the effort, but it's something to keep in mind.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolving this to land... Will unresolve once it lands.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though WPT is a moving target, it's highly unlikely for someone to remove a test from WPT - since it would be breaking change and something that's hard to justify.

@anonrig anonrig merged commit 2c071ca into main Dec 10, 2025
32 of 39 checks passed
@anonrig anonrig deleted the yagiz/v8-assert-bad-chunk branch December 10, 2025 22:25
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.

Fix V8 assert when decoding bad chunks

2 participants