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

addaleax
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 July 7, 2020 23:35
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 Issues or PRs related to the http subsystem. blocked PRs that are blocked by other issues or PRs. labels Jul 7, 2020
@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax removed the blocked PRs that are blocked by other issues or PRs. label Jul 14, 2020
@addaleax
Copy link
Member Author

@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 July 21, 2020 18:34
@danielleadams danielleadams added the review wanted PRs that need reviews. label Aug 4, 2020
@MylesBorins
Copy link
Contributor

ping @nodejs/http

Copy link
Member

@indutny indutny left a comment

Choose a reason for hiding this comment

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

LGTM

@BethGriggs
Copy link
Member

@lsr0
Copy link

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 PRs that need reviews. label Sep 20, 2020
@addaleax addaleax requested a review from a team as a September 22, 2020 08:48
@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@addaleax
Copy link
Member Author

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 Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Sep 22, 2020
@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member Author

Landed in 65b7bf4...867c451

@addaleax addaleax closed this Sep 22, 2020
addaleax added a commit that referenced this pull request 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 pull request 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 September 22, 2020 18:54
@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 Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants