Skip to content
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

Segmentation fault building 10.12.0 #23440

Closed
sido420 opened this issue Oct 12, 2018 · 18 comments
Closed

Segmentation fault building 10.12.0 #23440

sido420 opened this issue Oct 12, 2018 · 18 comments
Labels
build Issues and PRs related to build files or the CI. confirmed-bug Issues with confirmed bugs. v8 engine Issues and PRs related to the V8 dependency.

Comments

@sido420
Copy link

sido420 commented Oct 12, 2018

  • Version: 10.12.0
  • Platform:
    Ubuntu 17.10
    Linux version 4.13.0-46-generic (buildd@lcy01-amd64-002) (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)) Nominating Chris Dickinson to the TC #51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018
  • Subsystem:
    GNU Make 4.1
    gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0
    Python 2.7.14
wget -qO- https://github.com/nodejs/node/archive/v10.12.0.tar.gz | tar -xz
cd node-10.12.0/
./configure --prefix=/opt/nodejs --download=all --fully-static
make -j8

which fails with:

g++ -o /tmp/node-10.12.0/out/Release/genccode -pthread -rdynamic -m64  -Wl,--start-group /tmp/node-10.12.0/out/Release/obj.host/genccode/deps/icu-small/source/tools/genccode/genccode.o /tmp/node-10.12.0/out/Release/obj.host/genccode/tools/icu/no-op.o /tmp/node-10.12.0/out/Release/obj.host/tools/icu/libicutools.a -static -Wl,--end-group
Segmentation fault (core dumped)
deps/v8/gypfiles/v8_torque.host.mk:16: recipe for target 'cbaa0277bb5f5796abc8de7022f625e0be4aa200.intermediate' failed
make[1]: *** [cbaa0277bb5f5796abc8de7022f625e0be4aa200.intermediate] Error 139
make[1]: *** Waiting for unfinished jobs....
rm bfa79deccc09f1b7eb1e1c81a4d3b823493cc2f6.intermediate cbaa0277bb5f5796abc8de7022f625e0be4aa200.intermediate
Makefile:99: recipe for target 'node' failed
make: *** [node] Error 2
@addaleax addaleax added the build Issues and PRs related to build files or the CI. label Oct 12, 2018
@addaleax
Copy link
Member

I can reproduce this, although for me another command is failing (running torque). Maybe that’s because you specified -j8, so output from concurrent jobs ended up being interleaved?

@addaleax addaleax added confirmed-bug Issues with confirmed bugs. v8 engine Issues and PRs related to the V8 dependency. labels Oct 12, 2018
@sido420
Copy link
Author

sido420 commented Oct 12, 2018

@addaleax makes sense, you may be right
Another indication is that the master branch builds fine

git clone https://github.com/nodejs/node.git
cd node
 ./configure --prefix=/opt/nodejs --download=all --fully-static
make -j8

which ends with:

b_sock.c:(.text+0x2c6): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
rm e845f65070ebdefa6b5811cc5ff214e91df96af0.intermediate a4251d8138aad9391c3ac3ee2b3d46aa43c525de.intermediate 14f33af6882464e41d42019b7b6552fa1c8dd8b6.intermediate
if [ ! -r node -o ! -L node ]; then ln -fs out/Release/node node; fi

@addaleax
Copy link
Member

addaleax commented Oct 12, 2018

One moment I could reproduce this, another I couldn’t… it looked like things went wrong very early in the out/Release/torque process, so I would guess that there’s some kind of static initialization order issue or similar.

Edit: Yes, it looks like this happens because --static messes with the initialization order of libc/pthreads vs the rest of the code in some way.

@nilsmeyer
Copy link

Same problem with v10.16.0 (building on Ubuntu disco 19.04) when using --fully-static and LTO, torque is causing a segmentation fault.

[Sun Jul 14 10:56:39 2019] torque[6633]: segfault at 0 ip 0000000000000000 sp 00007ffd97be9018 error 14 in torque[400000+1000]
[Sun Jul 14 10:56:39 2019] Code: Bad RIP value.

@ghost
Copy link

ghost commented Jul 15, 2019

Subsystem:

GCC 8.2.0, GNU Make 4.2.1, Python 2.7.14

Any ideas when this is going to be fixed? I have no problem with producing a successful build with ./configure --fully-static on 9.10.1 however when attempting to build from 10.16.0 branch:

someuser@box:/tmp/dev/git/node$ git checkout tags/v10.16.0 -b v10.16.0

someuser@box:/tmp/dev/git/node$ ./configure --fully-static

creating icu_config.gypi
* Using ICU in deps/icu-small
WARNING: Using floating patch "tools/icu/patches/64/source/common/putil.cpp" from "tools/icu"
WARNING: Using floating patch "tools/icu/patches/64/source/i18n/dtptngen.cpp" from "tools/icu"
creating icu_config.gypi
{ 'target_defaults': { 'cflags': [],
                       'default_configuration': 'Release',
                       'defines': [],
                       'include_dirs': [],
                       'libraries': ['-static']},
  'variables': { 'asan': 0,
                 'build_v8_with_gn': 'false',
                 'coverage': 'false',
                 'debug_nghttp2': 'false',
                 'enable_lto': 'false',
                 'enable_pgo_generate': 'false',
                 'enable_pgo_use': 'false',
                 'force_dynamic_crt': 0,
                 'gas_version': '2.31',
                 'host_arch': 'x64',
                 'icu_data_in': '../../deps/icu-small/source/data/in/icudt64l.dat',
                 'icu_endianness': 'l',
                 'icu_gyp_path': 'tools/icu/icu-generic.gyp',
                 'icu_locales': 'en,root',
                 'icu_path': 'deps/icu-small',
                 'icu_small': 'true',
                 'icu_ver_major': '64',
                 'llvm_version': 0,
                 'node_byteorder': 'little',
                 'node_debug_lib': 'false',
                 'node_enable_d8': 'false',
                 'node_enable_v8_vtunejit': 'false',
                 'node_install_npm': 'true',
                 'node_module_version': 64,
                 'node_no_browser_globals': 'false',
                 'node_prefix': '/usr/local',
                 'node_release_urlbase': '',
                 'node_shared': 'false',
                 'node_shared_cares': 'false',
                 'node_shared_http_parser': 'false',
                 'node_shared_libuv': 'false',
                 'node_shared_nghttp2': 'false',
                 'node_shared_openssl': 'false',
                 'node_shared_zlib': 'false',
                 'node_tag': '',
                 'node_target_type': 'executable',
                 'node_use_bundled_v8': 'true',
                 'node_use_dtrace': 'false',
                 'node_use_etw': 'false',
                 'node_use_large_pages': 'false',
                 'node_use_openssl': 'true',
                 'node_use_pch': 'false',
                 'node_use_perfctr': 'false',
                 'node_use_v8_platform': 'true',
                 'node_with_ltcg': 'false',
                 'node_without_node_options': 'false',
                 'openssl_fips': '',
                 'openssl_no_asm': 0,
                 'shlib_suffix': 'so.64',
                 'target_arch': 'x64',
                 'v8_enable_gdbjit': 0,
                 'v8_enable_i18n_support': 1,
                 'v8_enable_inspector': 1,
                 'v8_no_strict_aliasing': 1,
                 'v8_optimized_debug': 0,
                 'v8_promise_internal_field_count': 1,
                 'v8_random_seed': 0,
                 'v8_trace_maps': 0,
                 'v8_typed_array_max_size_in_heap': 0,
                 'v8_use_snapshot': 'true',
                 'want_separate_host_toolset': 0}}
creating config.gypi
creating config.status
creating config.mk
running:
    python tools/gyp_node.py --no-parallel -f make-linux

someuser@box:/tmp/dev/git/node$ make -j 1

fail =>

make[1]: *** [deps/v8/gypfiles/v8_torque.host.mk:17: cd33b9389e9cd377c9ed7829b304dd6166939143.intermediate] Segmentation fault
make[1]: *** Deleting file 'cd33b9389e9cd377c9ed7829b304dd6166939143.intermediate'
make: *** [Makefile:99: node] Error 2

someuser@box:/tmp/dev/git/node$ make -j 4

fail =>

make[1]: *** [deps/v8/gypfiles/v8_torque.host.mk:17: cd33b9389e9cd377c9ed7829b304dd6166939143.intermediate] Segmentation fault
make[1]: *** Deleting file 'cd33b9389e9cd377c9ed7829b304dd6166939143.intermediate'
make[1]: *** Waiting for unfinished jobs....
/usr/local/bin/ld: /tmp/dev/git/node/out/Release/obj.target/openssl/deps/openssl/openssl/crypto/dso/dso_dlfcn.o: in function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x1b): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/bin/ld: /tmp/dev/git/node/out/Release/obj.target/openssl/deps/openssl/openssl/crypto/bio/b_addr.o: in function `BIO_lookup':
b_addr.c:(.text+0xb8b): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/bin/ld: /tmp/dev/git/node/out/Release/obj.target/openssl/deps/openssl/openssl/crypto/bio/b_sock.o: in function `BIO_gethostbyname':
b_sock.c:(.text+0x271): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
rm 909720c2063e37802a62afba2fe88cb178137014.intermediate
make: *** [Makefile:99: node] Error 2

@nilsmeyer
Copy link

Is this perhaps something we have to raise with upstream v8?

@mpaxson
Copy link

mpaxson commented Jul 30, 2019

+1

@ghost

This comment has been minimized.

@emerzon
Copy link

emerzon commented Sep 17, 2019

There seems to be multiple/different issues.

I have tried different setups:

  1. Alpine Linux + GCC8 and 9: --fully-static works, except when --enable-lto is also present, in this case the compilation will not fail, but the node binary will segfault.
  2. Ubuntu 19.04 - Compilation fails out of the box, torque binary segfaults during compilation.

@nilsmeyer
Copy link

nilsmeyer commented Sep 22, 2019

I've also tested with Fedora 29, the build works but the binary segfaults. It seems to me that both --enable-lto as well as --fully-static don't work and should be marked as unstable. I don't think this bug report gets any attention since it's for a fairly old version.

@emerzon
Copy link

emerzon commented Sep 26, 2019

Problem remains in 10.16.3

@gengjiawen
Copy link
Member

gengjiawen commented Sep 27, 2019

Step:

wget -qO- https://github.com/nodejs/node/archive/v10.16.3.tar.gz | tar -xz
cd node-10.16.3/
./configure --prefix=/opt/nodejs --download=all --fully-static
make -j8

Env

  System:
    OS: Linux 4.4 Ubuntu 19.10 (Eoan Ermine)
    CPU: (2) x64 Intel(R) Xeon(R) CPU @ 2.30GHz
    Memory: 7.00 GB / 7.30 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Utilities:
    CMake: 3.13.4 - /usr/bin/cmake
    Make: 4.2.1 - /usr/bin/make
    GCC: 9.2.1 - /usr/bin/gcc
    Git: 2.20.1 - /usr/bin/git
    Clang: 9.0.0-+rc5-1~exp1 - /usr/bin/clang
  IDEs:
    Vim: 8.1 - /usr/bin/vim
  Languages:
    Bash: 5.0.3 - /usr/bin/bash
    Perl: 5.28.1 - /usr/bin/perl
    Python: 2.7.16+ - /usr/bin/python
    Python3: 3.7.4+ - /usr/bin/python3
    R: 3.6.1 - /usr/bin/R
as: out of memory allocating 524411 bytes after a total of 131072 bytes
/bin/sh: 0: Cannot fork
virtual memory exhausted: Cannot allocate memory
/usr/lib/gcc/x86_64-linux-gnu/9/cc1plus: error while loading shared libraries: libc.so.6: failed to map segment from shared object
make[1]: execvp: printf: Cannot allocate memory
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/ANTLRErrorListener.o] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/tree/Trees.o] Error 127
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.o] Error 1
virtual memory exhausted: Cannot allocate memory
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.o] Error 1
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/atn/LexerMoreAction.o] Error 1
make[1]: *** [deps/v8/gypfiles/torque.host.mk:276: /node-10.16.3/out/Release/obj.host/torque/deps/v8/src/torque/implementation-visitor.o] Error 1
virtual memory exhausted: Cannot allocate memory

cc1plus: out of memory allocating 524168 bytes after a total of 3387392 bytes
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/atn/ErrorInfo.o] Error 1
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/RuntimeMetaData.o] Error 1

cc1plus: out of memory allocating 131048 bytes after a total of 2084864 bytes
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/atn/PredictionContext.o] Error 1
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/ANTLRErrorStrategy.o] Error 1
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/CommonTokenFactory.o] Error 1
virtual memory exhausted: Cannot allocate memory

cc1plus: out of memory allocating 32768 bytes after a total of 1605632 bytes
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/atn/StarLoopbackState.o] Error 1
virtual memory exhausted: Cannot allocate memory
make[1]: *** [deps/v8/gypfiles/torque.host.mk:276: /node-10.16.3/out/Release/obj.host/torque/deps/v8/src/torque/scope.o] Error 1
make[1]: *** [deps/v8/gypfiles/torque.host.mk:279: /node-10.16.3/out/Release/obj.host/torque/deps/v8/third_party/antlr4/runtime/Cpp/runtime/src/ParserInterpreter.o] Error 1
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory

cc1plus: out of memory allocating 131072 bytes after a total of 3694592 bytes
virtual memory exhausted: Cannot allocate memory

cc1plus: out of memory allocating 131072 bytes after a total of 2809856 bytes
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory

cc1plus: out of memory allocating 65528 bytes after a total of 1507328 bytes
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
make[1]: execvp: touch: Cannot allocate memory
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.

@jasnell
Copy link
Member

jasnell commented Jan 24, 2021

Is this still an issue? Does it need to remain open?

@gengjiawen
Copy link
Member

Is this still an issue? Does it need to remain open?

yeap. Has to wait Node 10 is EOL (2021-04-30) if no one fixes this.

@breisig
Copy link

breisig commented Feb 10, 2021

I think it's still might be happening with NodeJS 14.15.5 [ https://github.com//issues/37296 ]. I have enabled lto

@breisig
Copy link

breisig commented Feb 10, 2021

It seems if I remove --enable-lto from the configure line, it compiles without any issue.

@jasnell
Copy link
Member

jasnell commented Apr 26, 2021

Definitely not limited to 10.x

Refs: #35957
Refs: #38335

@jasnell jasnell removed the v10.x label Apr 26, 2021
@jasnell
Copy link
Member

jasnell commented May 12, 2021

I believe this can be closed now. A fix landed in master. It's possible that it is still an issue in v14.x but, if so, we can address that problem separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. confirmed-bug Issues with confirmed bugs. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

8 participants