Skip to content

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

Closed
addaleax wants to merge 3 commits into
nodejs:v12.x-stagingfrom
addaleax:http-sync-error
Closed

[v12.x] http: fix crash for sync write errors during header parsing#34251
addaleax wants to merge 3 commits into
nodejs:v12.x-stagingfrom
addaleax:http-sync-error

Conversation

@addaleax

@addaleaxaddaleax commented Jul 7, 2020

Copy link
Copy Markdown
Member
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

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
@addaleaxaddaleax 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
Copy Markdown
Collaborator

@addaleaxaddaleax removed the blocked PRs that are blocked by other issues or PRs. label Jul 14, 2020
@addaleax

Copy link
Copy Markdown
MemberAuthor

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

@codebytere
codebytereforce-pushed the v12.x-staging branch 2 times, most recently from b64963e to 3b1d9b3CompareJuly 21, 2020 18:34
@danielleadamsdanielleadams added the review wanted PRs that need reviews. label Aug 4, 2020
@MylesBorins

Copy link
Copy Markdown
Contributor

ping @nodejs/http

@indutnyindutny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@BethGriggs

Copy link
Copy Markdown
Member

@lsr0

lsr0 commented Sep 20, 2020

Copy link
Copy Markdown

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?

@addaleaxaddaleax 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
@addaleaxaddaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@addaleax

Copy link
Copy Markdown
MemberAuthor

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-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@addaleaxaddaleax 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
@addaleaxaddaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@addaleaxaddaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 22, 2020
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@addaleax

Copy link
Copy Markdown
MemberAuthor

Landed in 65b7bf4...867c451

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: #34251Fixes: #15102Fixes: #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
@codebyterecodebytere mentioned this pull request Sep 28, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

httpIssues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@addaleax@nodejs-github-bot@MylesBorins@BethGriggs@lsr0@indutny@Flarna@danielleadams