-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
node crashes with "free(): invalid pointer" when exiting #21845
Comments
Can you provide more information about your system? Which versions of Node.js did you test? Did you download the binaries from https://nodejs.org/en/, or was this installed through a package manager? Can you give more information about how this is related to crypto code? |
Sure, I did some research on the bug for a few days. This maybe looks like a report emmm... I can now sure this issue can be trigger by:
I am packaging for a Linux distribution, I built and tested the binaries. I found this does not crash:
i.e. without path prefix. And the memory mapping between two cases is different: Using gdb, I found OpenSSL called
( |
gdb showed the The direct reason of crashing is libstdc++ found the address of the |
From:
we can see why OpenSSL tries to dlopen() the main program itself. If OpenSSL is compiled to a shared object (libssl.so.???, libcrypto.so.???), it will try to keep itself(libcrypto.so in this case) loaded in two ways:
But this is pointless for us because node link the bundled OpenSSL statically. It becomes to dlopen the node instead of Why does node work fine without PIE?dlopen() cannot load an executable file. It failed silently. Home run! Why does node crash with PIE?PIE changes the type of executable files from ET_EXEC to ET_DYN, i.e. acts like a .so file, can be loaded by dlopen (accidentally). Why does node work fine without path?OpenSSL uses When it is "/bin/node", no modify is needed, Sent a PR for OpenSSL upstream here: openssl/openssl#6725 |
Postscript:
The iceberg under the surface is not so obvious anyways... Tested:
|
The statically linked program should not try to keep loaded by dlopen trick. Fixes: nodejs#21845 Refs: openssl/openssl#6725
@LionNatsu - does #28045 fix this? |
Thanks. I'll do a test to compare if it has fixed it ASAP |
The question for OpenSSL remains, I can't see why OpenSSL "pinshared" when it was built statically. Isn't there an option rule can toggle this automatically? Anyways, the bug was fixed. the new introduced |
Reproduce:
Backtrace:
The text was updated successfully, but these errors were encountered: