FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

zlib: fix crash when initializing failed by addaleax · Pull Request #14666 · nodejs/node · GitHub

/ node Public

zlib: fix crash when initializing failed - #14666

Closed
addaleax wants to merge 1 commit into
nodejs:masterfrom
addaleax:zlib-failed-init
Closed

zlib: fix crash when initializing failed#14666
addaleax wants to merge 1 commit into
nodejs:masterfrom
addaleax:zlib-failed-init

Conversation

addaleax commented Aug 7, 2017

Copy link
Copy Markdown
Member

Unset mode_ when initializing the zlib stream failed, so that we don’t try to call the zlib end functions (deflateEnd() etc.) when cleaning up in ZCtx::Close().

Fixes: #14178
Ref: #13098

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

src/zlib

Unset `mode_` when initializing the zlib stream failed, so that
we don’t try to call the zlib end functions (`deflateEnd()` etc.)
when cleaning up in `ZCtx::Close()`.

Fixes: nodejs#14178
Ref: nodejs#13098
addaleax added c++ Issues and PRs that require attention from people who are familiar with C++. lts-watch-v4.x zlib Issues and PRs related to the zlib subsystem. labels Aug 7, 2017
addaleax requested a review from aqrln August 7, 2017 15:18
nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. zlib Issues and PRs related to the zlib subsystem. labels Aug 7, 2017

addaleax commented Aug 7, 2017

Copy link
Copy Markdown
Member Author

gibfahn commented Aug 7, 2017

Copy link
Copy Markdown
Member

Is this a regression?

Looking at the description in #13098:

This PR fixes the Node process crashing when constructors of classes of the zlib module are given invalid options.

Throw an Error when the zlib library rejects the value of windowBits, instead of crashing with an assertion.

it sounds like zlib previously crashed under these circumstances anyway, so #13098 didn't make things worse. Is that correct?

gibfahn commented Aug 7, 2017
edited
Loading

Copy link
Copy Markdown
Member

+1 on fast-tracking this, if only because it'll make CI less red.

Is there an easy way to add a (less intermittently failing) test for this?

addaleax commented Aug 7, 2017

Copy link
Copy Markdown
Member Author

@gibfahn Right, it’s only going from an assertion failure to a segfault. It’s a bit more scary to see that happening, but it won’t really hurt anyone.

Is there an easy way to add a (less intermittent) test for this?

I don’t know, the failure is only happening because there’s uninitialized memory involved. I guess the best way to make sure this doesn’t happen again is to check the return value of the zlib cleanup functions, but tbh I’m scared to do that in a patch release given how complex the zlib state machine is.

addaleax mentioned this pull request Aug 7, 2017
2 tasks

addaleax commented Aug 7, 2017

Copy link
Copy Markdown
Member Author

@gibfahn I opened #14673, checking return values doesn’t seem to be enough to test this. I think more detailed CHECKs would require inspecting zlib internals.

Copy link
Copy Markdown
Contributor

@addaleax it was only partially backported... and we have not been seeing the failures on 6.x yet

Should we just revert the original change and call it a day?

MylesBorins mentioned this pull request Aug 8, 2017

gibfahn commented Aug 8, 2017

Copy link
Copy Markdown
Member

Should we just revert the original change and call it a day?

I'd rather land this if there are no problems with it. Reverting the original means zlib will still crash, which according to #13082 was a regression from 6.10.1->6.10.2 (due to the zlib update).

aqrln left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you!

addaleax commented Aug 9, 2017

Copy link
Copy Markdown
Member Author

Landed in 1e569f4

addaleax closed this Aug 9, 2017
addaleax deleted the zlib-failed-init branch August 9, 2017 17:59
addaleax added a commit that referenced this pull request Aug 9, 2017
Unset `mode_` when initializing the zlib stream failed, so that
we don’t try to call the zlib end functions (`deflateEnd()` etc.)
when cleaning up in `ZCtx::Close()`.

Fixes: #14178
Ref: #13098
PR-URL: #14666
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
addaleax added a commit that referenced this pull request Aug 9, 2017
Unset `mode_` when initializing the zlib stream failed, so that
we don’t try to call the zlib end functions (`deflateEnd()` etc.)
when cleaning up in `ZCtx::Close()`.

Fixes: #14178
Ref: #13098
PR-URL: #14666
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>

Copy link
Copy Markdown
Contributor

This has backported cleanly to v6.x
do we need to backport both fixes to v4.x? we are getting close to enough backlog to justify a maintenance release

MylesBorins pushed a commit that referenced this pull request Aug 12, 2017
Unset `mode_` when initializing the zlib stream failed, so that
we don’t try to call the zlib end functions (`deflateEnd()` etc.)
when cleaning up in `ZCtx::Close()`.

Fixes: #14178
Ref: #13098
PR-URL: #14666
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>

gibfahn commented Aug 12, 2017

Copy link
Copy Markdown
Member

do we need to backport both fixes to v4.x?

If we're planning to do another v4.x already it probably makes sense, these are fixes for zlib 1.2.11 which is the version in v4.x.

cc/ @aqrln @addaleax @lpinca

Copy link
Copy Markdown
Member Author

I probably would backport both fixes, but not backporting either also seems fine to me.

Copy link
Copy Markdown
Contributor

We are getting very close to a v4.x release. Could this please be backported to v4.x

MylesBorins mentioned this pull request Aug 16, 2017
aqrln pushed a commit to aqrln/node that referenced this pull request Aug 16, 2017
Unset `mode_` when initializing the zlib stream failed, so that
we don’t try to call the zlib end functions (`deflateEnd()` etc.)
when cleaning up in `ZCtx::Close()`.

Fixes: nodejs#14178
Ref: nodejs#13098
PR-URL: nodejs#14666
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>

aqrln commented Aug 16, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

@MylesBorins both fixes backported in #14860.

MylesBorins pushed a commit that referenced this pull request Sep 19, 2017
Unset `mode_` when initializing the zlib stream failed, so that
we don’t try to call the zlib end functions (`deflateEnd()` etc.)
when cleaning up in `ZCtx::Close()`.

Fixes: #14178
Ref: #13098
Backport-PR-URL: #14860
PR-URL: #14666
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
MylesBorins mentioned this pull request Sep 20, 2017
MylesBorins pushed a commit that referenced this pull request Oct 25, 2017
Unset `mode_` when initializing the zlib stream failed, so that
we don’t try to call the zlib end functions (`deflateEnd()` etc.)
when cleaning up in `ZCtx::Close()`.

Fixes: #14178
Ref: #13098
Backport-PR-URL: #14860
PR-URL: #14666
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
MylesBorins mentioned this pull request Oct 25, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. zlib Issues and PRs related to the zlib subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: parallel/test-zlib-failed-init, intermittent crash

7 participants


Back | FazBrowse Home | New Git URL