GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — v8: fix segmentation faults caused by IntegerValue by pmq20 · Pull Request #2722 · nodejs/node

Conversation

@pmq20

@pmq20 pmq20 commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

This PR fixes #2721 and adds a test to guard it.

Investigations show that the problem was caused by -O3 optimisations of the compiler. When building a debug version the segmentation fault won't be triggered. Moving the return statement inside the inner scope somehow fixes the malicious optimisation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rvagg

rvagg commented Sep 7, 2015

Copy link
Copy Markdown
Member

Weird, I'd love to lgtm this but I don't see why it would optimise that into a buggy state. Anyone else? @indutny, @bnoordhuis perhaps?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmq20
pmq20 force-pushed the minqi-pan-2721 branch from f6af2b2 to 958fe12 Compare September 7, 2015 11:46
@pmq20
v8: fix segmentation faults caused by IntegerValue
958fe12
@evanlucas

evanlucas commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

Switch from IntegerValue to Int32Value also fixes the issue.

diff --git a/src/process_wrap.cc b/src/process_wrap.cc
index adf1606..90e061f 100644
--- a/src/process_wrap.cc
+++ b/src/process_wrap.cc
@@ -98,7 +98,7 @@ class ProcessWrap : public HandleWrap {
         options->stdio[i].data.stream = stream;
       } else {
         Local<String> fd_key = env->fd_string();
-        int fd = static_cast<int>(stdio->Get(fd_key)->IntegerValue());
+        int fd = static_cast<int>(stdio->Get(fd_key)->Int32Value());
         options->stdio[i].flags = UV_INHERIT_FD;
         options->stdio[i].data.fd = fd;
       }

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

This needs to be upstreamed to V8 for us to accept it. One of the two already cc'd people should be abel to help with that. :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind

silverwind commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

Both patches fix the segfaults for me. While it should be upstreamed, I'd much prefer if we float this now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind silverwind mentioned this pull request Sep 7, 2015
Yet another segmentation fault in node-v4.0.0-rc.1 #2721
Closed
@silverwind silverwind added c++ Issues and PRs that require attention from people who are familiar with C++. v8 engine Issues and PRs related to the V8 dependency. labels Sep 7, 2015
@mscdex

mscdex commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

+1 to floating in the meantime or using @evanlucas's proposed change on our side, especially if we want to get 4.0.0 out today/tomorrow.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind

silverwind commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

ping @pmq20: care to change it to @evanlucas's suggestion?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Sep 7, 2015
DO NOT MERGE: Reproduce segmentation faults related to IntegerValue (#2721) #2725
Closed
Workaround for crash in #2721 on 4.0.0-rc #2726
Closed
@brody2consult

brody2consult commented Sep 7, 2015

Copy link
Copy Markdown

I just issued #2726 with the workaround solution by @evanlucas on the v4.0.0-rc branch. I hope we can get them to fix it in v8 in the near future.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@evanlucas

evanlucas commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

This is a bug in child_process, _validateStdio specifically. #2727

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex mscdex added the child_process Issues and PRs related to the child_process subsystem. label Sep 7, 2015
@indutny

indutny commented Sep 7, 2015

Copy link
Copy Markdown
Member

I don't like landing things that I do not understand. May I ask you to dump assembly output from this function before and after your patch?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@evanlucas

evanlucas commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

@indutny sure, know of the best way to do that on OS X?

In short, _validateStdio was setting the fd value to the stdio object instead of stdio.fd in the event that fd === 0. A number was expected whenever the type is fd

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 7, 2015

Copy link
Copy Markdown
Member

Oh, this is reproducible on mac? I'll do the dumps myself then.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@evanlucas

evanlucas commented Sep 7, 2015

Copy link
Copy Markdown
Contributor

Yes

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 7, 2015

Copy link
Copy Markdown
Member

This is a somewhat better fix for this problem: #2730 . This removes the cause of the problem. The problem itself is not yet clear to me, but I hope it fixes the crashes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 7, 2015

Copy link
Copy Markdown
Member

Nevermind that PR. @evanlucas already figured it out, I just didn't listen well to him. I think I know what the problem is... investigating!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 7, 2015

Copy link
Copy Markdown
Member

Please do not land it yet, I'm very close to the resolution. The problem is with the handle zapping, and this PR is somewhat a solution for this, but I want to be sure before we do anything like this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 7, 2015

Copy link
Copy Markdown
Member

After some thinking, I think we should land: #2727 , and submit this patch to the v8 team. Please let me know if you need help setting up the environment for this.

I'm against landing it without v8 team review, but overall I think that this is the right solution for the problem.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 7, 2015

Copy link
Copy Markdown
Member

Also, please cc me on that CL. I will provide all required information to the v8 team.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind silverwind mentioned this pull request Sep 7, 2015
child_process: use stdio.fd even if it is 0 #2727
Merged
@bnoordhuis bnoordhuis mentioned this pull request Sep 7, 2015
Fix v8_enable_handle_zapping for 4.5 #2731
Closed
@bnoordhuis

bnoordhuis commented Sep 7, 2015

Copy link
Copy Markdown
Member

I left a comment here with details but in a nutshell, I think this PR is correct in that it fixes an insidious scope bug in the else block of Value::IntegerValue().

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rvagg

rvagg commented Sep 7, 2015

Copy link
Copy Markdown
Member

OK folks, we have this, #2727 and #2731 with none resolved. From what I can see from the discussion, both this and #2727 look like candidates for landing and have close enough to approval to go in and #2731 seems to have approval although is apparently not the appropriate fix for the bug, just a nice thing to have.

We have to get v4.0.0 out, the timeline we are working to now has ~12 hours less, could owners of these issues or other collaborators involved who understand the issue please step up and merge what should be merged and close anything that shouldn't be merged. I'll push out an rc.3 if we get this done in enough time to bother.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 8, 2015

Copy link
Copy Markdown
Member

@rvagg #2727 is almost good to go. If @evanlucas won't have to fix it himself - I'll do it for him.

#2731 is not bad to have, but is not a fix for this problem either.

and this PR is a "no go" in our repo, it should be submitted and landed in V8, #2727 is enough to fix the problem on our side.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 8, 2015

Copy link
Copy Markdown
Member

@rvagg and we are good now since 3bc7e58 just landed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 8, 2015

Copy link
Copy Markdown
Member

I'd still look into landing #2731, though, but this depends on @bnoordhuis availability.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind

silverwind commented Sep 8, 2015

Copy link
Copy Markdown
Contributor

Looks this PR is obsolete now, Thanks for your work in discovering this thought, @pmq20.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@silverwind silverwind closed this Sep 8, 2015
@indutny

indutny commented Sep 8, 2015

Copy link
Copy Markdown
Member

@pmq20 let's work together to submit this to v8 team.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmq20

pmq20 commented Sep 8, 2015

Copy link
Copy Markdown
Contributor Author

@indutny @silverwind Sorry for the delayed reply. I work in the +8 time zone and just woke up so there's a lot for me to catch up.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmq20

pmq20 commented Sep 8, 2015

Copy link
Copy Markdown
Contributor Author

@indutny OK, I'll write a test to reproduce the bug on the sole v8 land.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 8, 2015

Copy link
Copy Markdown
Member

@pmq20 take a look at cctest-api. This is something that you might be interested in, also your test should call ->IntegerValue() on Object or any non-number value.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmq20

pmq20 commented Sep 8, 2015

Copy link
Copy Markdown
Contributor Author

@indutny Thanks for the hint! Looking into it

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmq20

pmq20 commented Sep 8, 2015

Copy link
Copy Markdown
Contributor Author

@indutny @bnoordhuis @skomski

I have added a v8 test and submitted a CL, let's continue the discussion there.
https://codereview.chromium.org/1303093004/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Sep 8, 2015

Copy link
Copy Markdown
Member

Yay, thank you!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aliscco aliscco mentioned this pull request May 14, 2024
[Snyk] Fix for 2 vulnerabilities aliscco/alisco-node#1459
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

9 participants

@pmq20 @rvagg @evanlucas @Fishrock123 @silverwind @mscdex @brody2consult @indutny @bnoordhuis
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.