-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
[RESOLVED] Node addon which uses std::unordered_set
will crash on Node.js 9.3.0
#17817
Comments
std::unordered_set
will crash on Node.js 9.3.0std::unordered_set
will crash on Node.js 9.3.0
Thanks for the detailed bug report. I don't have an easy way to reproduce but my first hunch would be a libstdc++ ABI issue. Does it work when you add a Relevant links: https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html |
I've tried to add the flag but it doesn't fix the crash. {
"targets": [
{
"target_name": "addon",
"sources": [ "hello.cpp" ],
'cflags': [ '-fabi-version=7' ],
'cflags_cc': [ '-fabi-version=7' ]
}
]
} |
Does this happen regardless if you build Node.js yourself or use the official binary? |
Sounds possibly like some kind of uninitialized memory usage/corruption… @fs-eire have you tried using Valgrind? I’ll try to reproduce later today. |
@TimothyGu No I didn't. Actually I know it just now. Will learn how to use it later. BTW, I am not sure whether the crash is introduced in the specific commit or not... It may be a good idea to reproduce with |
Happy new year guys :) Any updates on this issue? |
The crash is still happening in Node 9.4.0 Is anyone investigating this issue? |
I don't think so. I wasn't able to reproduce with ubuntu 14.04 + g++ 4.8 (like you said) and I wasn't quite ready to upgrade to g++ >= 5. |
@bnoordhuis Yes the crash only happens with the binary that built by G++ >=5. There is no worry about upgrading G++ to 5. You can have both G++4.x and 5.x installed and use |
Recently I found this issue is also happening in Node.js 8.10.0 (8.9.4 is no problem) Is there a way to get rid of this issue? |
I can't reproduce this problem with Node 8.10.0 or Node 9.10.1 compiled with g++ (SUSE Linux) 7.3.1 20180307 [gcc-7-branch revision 258314]
compiler problem? |
@AdamMajer me too. The problem only happen on gcc5.x/6.x+Ubuntu14.04. Other compiler/platform combination does not have this issue. May be a compiler problem, or compiler-OS compatibility problem. |
Node executable exposes some symbols that defined in stdlibc++.so When addon links to the same symbol, the wrong address may be used and causes crash. Specifically, the commit mentioned above instantiate a This issue actually exists on Windows, too. By specifying I'm not that familiar with linux platform, I'd be appreciated if you can help. @AdamMajer @bnoordhuis Also, I think the best solution is to limit node executable to expose any symbols that from standard library. |
Okay, that sounds plausible. This however:
...isn't quite correct. That said, being more discriminate with what we export is a good idea. (But not entirely trivial to implement - you can find discussions going back at least five years.) |
@bnoordhuis Thanks for the information! Regarding this-
I am not sure if this can be done. From the build log outputted by
It looks no link order concern since the only one object linked is hello.o. I've tried several ways but cannot solve it.. Node seems always prefer the one inside when the same symbol exists in both node and addon.node 😞 |
Does it work when you add |
Seems not working with Using |
Huh, so it's weak? That explains why the symbol from the node binary is used but it's weird that it's weak. What happens when you add a |
No change happens to addon.node. BTW, the symbol is also W in node. And a bunch other STL types are also W in addon.node and node. |
Ah wait, I mean |
So node is the program who overrides the definition in addon.node. For addon, it looks a good idea to always specify those flags unless there is a reason not to. It's still a mystery to me why the crash happens on some of the OS/compiler combinations and not on the others... |
std::unordered_set
will crash on Node.js 9.3.0std::unordered_set
will crash on Node.js 9.3.0
does this need to remain open? |
Seems like it's been resolved. |
A simple node addon which uses
std::unordered_set
will crash on Node.js 9.3.0• This crash starts in commit cf7e15c . ( identified by
git bisect
)• Happens in Ubuntu 14.04. Does NOT happen on Windows/mac OS/Ubuntu 16.04
• Happens in G++5.x and G++6.x. Does NOT happen on G++4.x.
• Here is the link to travis Cl build which contains the stacktrace info from core dump.
• Here is the corresponding code. ( A modified hello-world addon )
EDIT (2018-05-01):
Solution: add linker flag
'ldflags': ['-Wl,-Bsymbolic', '-Wl,-Bsymbolic-functions']
to resolve this issue.The text was updated successfully, but these errors were encountered: