nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.78k stars 29.68k forks source link

Problem with build Node v0.10.x on ARM Linux #4926

Closed kkeker closed 8 years ago

kkeker commented 8 years ago

I am installing this product for instructions https://www.openproject.org/open-source/manual-installation/manual-installation-4-0/ and it requires version node 0.10.x

I tried to compile Node from source on Ubuntu 14 for ARM version node-v0.10.33 and node-v0.10.41 configured both versions are compiled and installed with no problems, but npm does not work!

Example output: root@odroid-server: ~ # node -v v0.10.33 root@odroid-server: ~ # npm -v Segmentation fault (core dumped)

bnoordhuis commented 8 years ago

Does e.g. node -e 'console.log(42)' work or does it also segfault? If it segfaults, can you post the output of this?

$ gdb --args node -e 'console.log(42)'
> run
# wait for crash
> thread apply all backtrace full
# ...
> disassemble $pc,$pc+32

Disclaimer: there is no official support for v0.10 on ARM. If you want a version of node.js that is known to work well on ARM, upgrade to v4.x. You can download official release binaries from https://nodejs.org/dist/

kkeker commented 8 years ago
root@odroid-server:/home/openproject# node -e 'console.log(42)'
Segmentation fault (core dumped)

root@odroid-server:/home/openproject# gdb --args node -e 'console.log(42)'
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...done.
(gdb) run
Starting program: /usr/local/bin/node -e console.log\(42\)
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x00236ba8 in _armv7_tick ()
(gdb) disassemble $pc,$pc+32
Dump of assembler code from 0x236ba8 to 0x236bc8:
=> 0x00236ba8 <_armv7_tick+0>:  mrc     15, 0, r0, cr9, cr13, {0}
   0x00236bac <_armv7_tick+4>:  bx      lr
   0x00236bb0 <OPENSSL_atomic_add+0>:   ldrex   r2, [r0]
   0x00236bb4 <OPENSSL_atomic_add+4>:   add     r3, r2, r1
   0x00236bb8 <OPENSSL_atomic_add+8>:   strex   r2, r3, [r0]
   0x00236bbc <OPENSSL_atomic_add+12>:  cmp     r2, #0
   0x00236bc0 <OPENSSL_atomic_add+16>:  bne     0x236bb0 <OPENSSL_atomic_add>
   0x00236bc4 <OPENSSL_atomic_add+20>:  mov     r0, r3
End of assembler dump.

configure.txt make.txt

For this task, I can not use node 4.x or node 5.x (by the way there is no problem with them, if you use ready-made binary version), because installer of this project is used to specify a particular version node and npm, I think the reasons for this.

[edit: bnoordhuis - quoted output]

bnoordhuis commented 8 years ago

Can you also post the backtrace?

bnoordhuis commented 8 years ago

Oh, let me amend that: can you type continue a few times until gdb tells you it can't continue? That SIGILL is benign, it's openssl's feature detection.

kkeker commented 8 years ago

I do not understand that I am required to ...

bnoordhuis commented 8 years ago

And I in turn don't quite understand what you're saying... When you get that Program received signal SIGILL, Illegal instruction. message, please type continue in gdb - that particular error is benign and can be skipped over.

If that doesn't work for you, start over but type handle SIGILL nostop before you type run.

kkeker commented 8 years ago
root@odroid-server:~# gdb --args node -e 'console.log(42)'
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...done.
(gdb) run
Starting program: /usr/local/bin/node -e console.log\(42\)

Program received signal SIGILL, Illegal instruction.
dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:1597
1597    rtld.c: No such file or directory.
(gdb) continue
Continuing.

Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb) continue
The program is not being run.
(gdb) disassemble $pc,$pc+32
No registers.
bnoordhuis commented 8 years ago

Can you try handle SIGILL nostop before run?

silverwind commented 8 years ago

Couldn't reproduce this crash on my RPi2 running Arch Linux ARM and node v0.10.41.

kkeker commented 8 years ago
root@odroid-server:~# gdb --args node -e 'console.log(42)'
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...done.
(gdb) handle SIGILL nostop
Signal        Stop      Print   Pass to program Description
SIGILL        No        Yes     Yes             Illegal instruction
(gdb) run
Starting program: /usr/local/bin/node -e console.log\(42\)

Program received signal SIGILL, Illegal instruction.

Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb) continue
The program is not being run.
(gdb) disassemble $pc,$pc+32
No registers.
kkeker commented 8 years ago

I use this http://www.hardkernel.com/main/products/prdt_info.php?g_code=G143452239825

root@odroid-server:~# cat /etc/issue Ubuntu 14.04.3 LTS \n \l

root@odroid-server:~# uname -a Linux odroid-server 3.10.82 #1 SMP PREEMPT Tue Jul 14 01:28:23 BRT 2015 armv7l armv7l armv7l GNU/Linux

kkeker commented 8 years ago

This is my test bench, if necessary I can provide access to it, it does not have any value, and then later I will reinstall the operating system, so it can perform any operations without fear.

bnoordhuis commented 8 years ago

Okay, let's try something else. Can you try this?

# On the command line:
$ ulimit -c unlimited
$ node -e 'console.log(42)'
$ gdb node core  # `core` may be `core.<pid>`, look in the current directory
# in gdb
> thread apply all backtrace full
> disassemble $pc,$pc+32
kkeker commented 8 years ago
root@odroid-server:~# ulimit -c unlimited
root@odroid-server:~# node -e 'console.log(42)'
Segmentation fault (core dumped)
root@odroid-server:~# gdb node core
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...done.
[New LWP 2422]
[New LWP 2423]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
Core was generated by `node -e console.log(42)'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000 in ?? ()
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
(gdb) thread apply all backtrace full

Thread 2 (Thread 0xb6cbf450 (LWP 2423)):
#0  0xb6d31960 in nanosleep () at ../sysdeps/unix/syscall-template.S:81
No locals.
#1  0xb6d4efc8 in usleep (useconds=900) at ../sysdeps/unix/sysv/linux/usleep.c:32
        ts = {tv_sec = 0, tv_nsec = 900000}
#2  0x003fc558 in v8::internal::SignalSender::Run() ()
No symbol table info available.
#3  0x003fb59e in v8::internal::ThreadEntry(void*) ()
No symbol table info available.
#4  0xb6dacfbc in start_thread (arg=0xb6cbf450) at pthread_create.c:314
        pd = 0xb6cbf450
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1228147096, -1228147632, 0, -1228149176, -1228148848, 0, -1228147068, -1095551736, -896818754, -895844241, 0 <repeats 54 times>},
              mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = 0
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#5  0xb6d5320c in ?? () at ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S:92 from /lib/arm-linux-gnueabihf/libc.so.6
No locals.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0xb6f37000 (LWP 2422)):
#0  0x00000000 in ?? ()
No symbol table info available.
#1  0x4e80a15c in ?? ()
No symbol table info available.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) disassemble $pc,$pc+32
Dump of assembler code from 0x0 to 0x20:
=> 0x00000000:  Cannot access memory at address 0x0
(gdb)
root@odroid-server:~# ls -la | grep core
-rw-------  1 root        root         3182592 Jan 28 23:17 core

core.zip

bnoordhuis commented 8 years ago

The backtrace doesn't really provide a clue, I'm afraid. Best suggestion I can give you is that if you need to use v0.10, upgrade to v0.10.41.

kkeker commented 8 years ago

On 0.10.41 the same problem, I'll remove the old version, the new compile and show you the results.

kkeker commented 8 years ago
root@odroid-server:/home/openproject# cd node-v0.10.41
root@odroid-server:/home/openproject/node-v0.10.41# ./configure > /root/node-v0.10.41-configure.txt
root@odroid-server:/home/openproject/node-v0.10.41# make > /root/node-v0.10.41-make.txt
../deps/cares/src/ares_process.c: In function 'read_udp_packets':
../deps/cares/src/ares_process.c:481:35: warning: pointer targets in passing argument 6 of 'recvfrom' differ in signedness [-Wpointer-sign]
                                   0, &from.sa, &fromlen);
                                   ^
In file included from /usr/include/arm-linux-gnueabihf/sys/socket.h:280:0,
                 from ../deps/cares/src/ares_process.c:21:
/usr/include/arm-linux-gnueabihf/bits/socket2.h:64:1: note: expected 'socklen_t * __restrict__' but argument is of type 'ares_socklen_t *'
 recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
 ^
../deps/v8/src/hydrogen.cc: In member function 'void v8::internal::BoundsCheckBbData::MoveIndexIfNecessary(v8::internal::HValue*, v8::internal::HBoundsCheck*, v8::internal::HInstruction*)':
../deps/v8/src/hydrogen.cc:3558:10: warning: variable 'must_move_index' set but not used [-Wunused-but-set-variable]
     bool must_move_index = false;
          ^
../deps/zlib/gzlib.c: In function 'gz_open':
../deps/zlib/gzlib.c:256:9: warning: implicit declaration of function 'lseek' [-Wimplicit-function-declaration]
         state->start = LSEEK(state->fd, 0, SEEK_CUR);
         ^
../deps/zlib/gzread.c: In function 'gz_load':
../deps/zlib/gzread.c:30:9: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration]
         ret = read(state->fd, buf + *have, len - *have);
         ^
../deps/zlib/gzread.c: In function 'gzclose_r':
../deps/zlib/gzread.c:591:5: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration]
     ret = close(state->fd);
     ^
../deps/zlib/gzwrite.c: In function 'gz_comp':
../deps/zlib/gzwrite.c:84:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
         got = write(state->fd, strm->next_in, strm->avail_in);
         ^
../deps/zlib/gzwrite.c: In function 'gzclose_w':
../deps/zlib/gzwrite.c:573:5: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration]
     if (close(state->fd) == -1)
     ^
In file included from ../src/v8_typed_array.cc:27:0:
../src/v8_typed_array_bswap.h: In function 'T v8_typed_array::SwapBytes(T)':
../src/v8_typed_array_bswap.h:125:16: warning: typedef 'NoSwapBytesForType' locally defined but not used [-Wunused-local-typedefs]
   typedef char NoSwapBytesForType[sizeof(T) == 0 ? 1 : -1];
                ^
../src/v8_typed_array_bswap.h: In function 'T v8_typed_array::LoadAndSwapBytes(void*) [with T = float]':
../src/v8_typed_array_bswap.h:155:16: warning: typedef 'VerifySizesAreEqual' locally defined but not used [-Wunused-local-typedefs]
   typedef char VerifySizesAreEqual[sizeof(uint32_t) == sizeof(float) ? 1 : -1];
                ^
../src/v8_typed_array_bswap.h: In function 'T v8_typed_array::LoadAndSwapBytes(void*) [with T = double]':
../src/v8_typed_array_bswap.h:166:16: warning: typedef 'VerifySizesAreEqual' locally defined but not used [-Wunused-local-typedefs]
   typedef char VerifySizesAreEqual[sizeof(uint64_t) == sizeof(double) ? 1 : -1];
                ^
../src/v8_typed_array_bswap.h: In function 'void v8_typed_array::SwapBytesAndStore(void*, T) [with T = float]':
../src/v8_typed_array_bswap.h:183:16: warning: typedef 'VerifySizesAreEqual' locally defined but not used [-Wunused-local-typedefs]
   typedef char VerifySizesAreEqual[sizeof(uint32_t) == sizeof(float) ? 1 : -1];
                ^
../src/v8_typed_array_bswap.h: In function 'void v8_typed_array::SwapBytesAndStore(void*, T) [with T = double]':
../src/v8_typed_array_bswap.h:192:16: warning: typedef 'VerifySizesAreEqual' locally defined but not used [-Wunused-local-typedefs]
   typedef char VerifySizesAreEqual[sizeof(uint64_t) == sizeof(double) ? 1 : -1];
                ^
root@odroid-server:/home/openproject/node-v0.10.41#

node-v0.10.41-configure.txt node-v0.10.41-make.txt


root@odroid-server:/home/openproject/node-v0.10.41# cd ..
root@odroid-server:/home/openproject# node -v
v0.10.41
root@odroid-server:/home/openproject# npm -v
Segmentation fault (core dumped)
root@odroid-server:/home/openproject# node -e 'console.log(Hello)'
Segmentation fault (core dumped)
root@odroid-server:/home/openproject#
kkeker commented 8 years ago
root@odroid-server:/home/openproject# ulimit -c unlimited
root@odroid-server:/home/openproject# node -e 'console.log(42)'
Segmentation fault (core dumped)
root@odroid-server:/home/openproject# gdb node core
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...done.

warning: core file may not match specified executable file.
[New LWP 23081]
[New LWP 23082]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
Core was generated by `/usr/local/bin/node /usr/local/bin/npm -v'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000 in ?? ()
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
(gdb) thread apply all backtrace full

Thread 2 (Thread 0xb6cb7450 (LWP 23082)):
#0  0xb6d29960 in nanosleep () at ../sysdeps/unix/syscall-template.S:81
No locals.
#1  0xb6d46fc8 in usleep (useconds=900) at ../sysdeps/unix/sysv/linux/usleep.c:32
        ts = {tv_sec = 0, tv_nsec = 900000}
#2  0x003fdf98 in v8::internal::SignalSender::Run() ()
No symbol table info available.
#3  0x003fcfee in v8::internal::ThreadEntry(void*) ()
No symbol table info available.
#4  0xb6da4fbc in start_thread (arg=0xb6cb7450) at pthread_create.c:314
        pd = 0xb6cb7450
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1228179864, -1228180400, 0, -1228181944, -1228181616, 0, -1228179836, -1097009976, 1765556495, 1764581598, 0 <repeats 54 times>},
              mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = 0
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#5  0xb6d4b20c in ?? () at ../ports/sysdeps/unix/sysv/linux/arm/nptl/../clone.S:92 from /lib/arm-linux-gnueabihf/libc.so.6
No locals.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0xb6f2f000 (LWP 23081)):
#0  0x00000000 in ?? ()
No symbol table info available.
#1  0x5df0a15c in ?? ()
No symbol table info available.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) disassemble $pc,$pc+32
Dump of assembler code from 0x0 to 0x20:
=> 0x00000000:  Cannot access memory at address 0x0
(gdb)

core.zip

bnoordhuis commented 8 years ago

Sorry, missed the GH notification. Honestly, I don't know what to make of it. The stack trace for thread 1 is obviously corrupted (it seems to be making a jump to address 0, disassembly of 0x5df0a15c,+32 will probably confirm that) but the why is unclear.

I'll repeat that the best advice I can give you is to upgrade. :-) Newer versions of node are known to work well on ARM. If you have dependencies that are stuck on v0.10, cajole them into upgrading.

kkeker commented 8 years ago

Many thanks! Now create a task the authors of the project, they may update your code to a newer version Node.JS :-)