Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v12.x] http: fix crash for sync write errors during header parsing #34251

Closed
wants to merge 3 commits into from

Conversation

Copy link
Member

@addaleax addaleax commented Jul 7, 2020

http: fix crash for sync write errors during header parsing

Fix a crash that occurs when parser.finish() is called during
parser.execute(). In this particular case, this happened because
a 100 continue response is a place in which .end() can be called
which can in turn lead to a write error, which is emitted
synchronously, thus inside the outer parser.execute() call.

Resolve that by delaying the parser.finish() call until after
the parser.execute() call is done.

This only affects v12.x, because on later versions, errors are not
emitted synchronously.

Fixes: #15102
Fixes: #34016

test: add regression tests for HTTP parser crash

Since the tests only crash on v12.x, this commit adds separate
regression tests.

Refs: #15102
Refs: #34016

[This is #34250, which this PR is blocked on.]

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

addaleax added 2 commits Jul 7, 2020
Fix a crash that occurs when `parser.finish()` is called during
`parser.execute()`. In this particular case, this happened because
a 100 continue response is a place in which `.end()` can be called
which can in turn lead to a write error, which is emitted
synchronously, thus inside the outer `parser.execute()` call.

Resolve that by delaying the `parser.finish()` call until after
the `parser.execute()` call is done.

This only affects v12.x, because on later versions, errors are not
emitted synchronously.

Fixes: nodejs#15102
Since the tests only crash on v12.x, this commit adds separate
regression tests.

Refs: nodejs#15102
@addaleax addaleax added http blocked labels Jul 7, 2020
@nodejs-github-bot nodejs-github-bot added the v12.x label Jul 7, 2020
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jul 7, 2020

@addaleax addaleax removed the blocked label Jul 14, 2020
@addaleax
Copy link
Member Author

@addaleax addaleax commented Jul 14, 2020

@nodejs/http Can anybody review this? Only the first commit needs reviews, the remainder is just a backport of #34250

@codebytere codebytere force-pushed the v12.x-staging branch 2 times, most recently from b64963e to 3b1d9b3 Compare Jul 21, 2020
@danielleadams danielleadams added the review wanted label Aug 4, 2020
@MylesBorins
Copy link
Member

@MylesBorins MylesBorins commented Aug 18, 2020

Copy link
Member

@indutny indutny left a comment

LGTM

@BethGriggs
Copy link
Member

@BethGriggs BethGriggs commented Aug 18, 2020

@lsr0
Copy link

@lsr0 lsr0 commented Sep 20, 2020

Can I ask what is left in the process to get this merged into 12.x, or if there is anything we can do to help?

@addaleax addaleax removed the review wanted label Sep 20, 2020
@addaleax addaleax requested a review from as a Sep 22, 2020
@addaleax addaleax added the request-ci label Sep 22, 2020
@addaleax
Copy link
Member Author

@addaleax addaleax commented Sep 22, 2020

Can I ask what is left in the process to get this merged into 12.x, or if there is anything we can do to help?

@lsr0 I don’t think there’s anything missing here, I’ll try to make sure it goes into the next release.

@github-actions github-actions bot removed the request-ci label Sep 22, 2020
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 22, 2020

@addaleax addaleax added request-ci and removed request-ci labels Sep 22, 2020
@addaleax addaleax added the request-ci label Sep 22, 2020
@github-actions github-actions bot removed the request-ci label Sep 22, 2020
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 22, 2020

@addaleax addaleax added the request-ci label Sep 22, 2020
@github-actions github-actions bot removed the request-ci label Sep 22, 2020
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 22, 2020

@addaleax
Copy link
Member Author

@addaleax addaleax commented Sep 22, 2020

Landed in 65b7bf4...867c451

@addaleax addaleax closed this Sep 22, 2020
addaleax added a commit that referenced this issue Sep 22, 2020
Fix a crash that occurs when `parser.finish()` is called during
`parser.execute()`. In this particular case, this happened because
a 100 continue response is a place in which `.end()` can be called
which can in turn lead to a write error, which is emitted
synchronously, thus inside the outer `parser.execute()` call.

Resolve that by delaying the `parser.finish()` call until after
the `parser.execute()` call is done.

This only affects v12.x, because on later versions, errors are not
emitted synchronously.

PR-URL: #34251
Fixes: #15102
Fixes: #34016
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
addaleax added a commit that referenced this issue Sep 22, 2020
Since the tests only crash on v12.x, this commit adds separate
regression tests.

PR-URL: #34251
Refs: #15102
Refs: #34016
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
@addaleax addaleax deleted the http-sync-error branch Sep 22, 2020
@codebytere codebytere mentioned this pull request Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http v12.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants