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

Node fails to start on MTK7620: "Illegal instruction" #4818

Closed
Nicholasny opened this issue Jan 22, 2016 · 10 comments
Closed

Node fails to start on MTK7620: "Illegal instruction" #4818

Nicholasny opened this issue Jan 22, 2016 · 10 comments
Labels
build Issues and PRs related to build files or the CI. mips Issues and PRs related to the MIPS architecture.

Comments

@Nicholasny
Copy link

I cross compiled nodejs for a MIPSel target (without FPU but FPU emulation in the kernel) using the OpenWRT 15.05 Chaos Calmer toolchain. The target CPU is an MT7620A

I compile using:
./configure --without-snapshot --dest-cpu=mipsel --dest-os=linux --without-npm --without-ssl --without-etw --without-perfctr --with-mips-float-abi=soft

However then I run into the problem is describing.
"Illegal instruction"
on any of the js files in the test directory.
I can execute node -v, but not node test.js, or node debug test.js

information see below:

root@OpenWrt:/# cat /proc/cpuinfo
system type     : MediaTek MT7620A ver:2 eco:3
machine         : Ralink MT7620a + MT7610e evaluation board
processor       : 0
cpu model       : MIPS 24KEc V5.0
BogoMIPS        : 385.84
wait instruction    : yes
microsecond timers  : yes
tlb_entries     : 32
extra interrupt vector  : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa         : mips1 mips2 mips32r1 mips32r2
ASEs implemented    : mips16 dsp
shadow register sets    : 1
kscratch registers  : 0
package         : 0
core            : 0
VCED exceptions     : not available
VCEI exceptions     : not available

root@OpenWrt:/# cat /proc/version
Linux version 3.18.23 (root@169da0c77da5) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r47992) ) #47 Thu Jan 21 00:54:13 UTC 2016

root@OpenWrt:/# node -v
v0.12.7

root@OpenWrt:/# which  node
/usr/bin/node

root@OpenWrt:/# node -v
v0.12.7

root@OpenWrt:/# ldd /usr/bin/node
    libz.so.1 => /usr/lib/libz.so.1 (0x77881000)
    libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x77823000)
    libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x776be000)
    librt.so.0 => /lib/librt.so.0 (0x776aa000)
    libdl.so.0 => /lib/libdl.so.0 (0x77696000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x775ae000)
    libm.so.0 => /lib/libm.so.0 (0x77588000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x77564000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x7753e000)
    libc.so.0 => /lib/libc.so.0 (0x774d2000)
    ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x778a4000)
@bnoordhuis
Copy link
Member

Can you run gdb --args node test.js -> run -> disassemble $pc,$pc+32 (after the SIGILL)?

@bnoordhuis bnoordhuis added the mips Issues and PRs related to the MIPS architecture. label Jan 22, 2016
@bnoordhuis
Copy link
Member

Aside, it's odd that you ran configure with --without-ssl but the binary is linked against libcrypto and libssl.

@mscdex mscdex added the build Issues and PRs related to build files or the CI. label Jan 22, 2016
@Nicholasny
Copy link
Author

root@OpenWrt:/# cat test.js
console.log("hello");

root@OpenWrt:~# gdb --args node test.js
GNU gdb (GDB) 7.8
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 "mipsel-openwrt-linux".
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/bin/node test.js
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: File "/lib/libthread_db-0.9.33.2.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /lib/libthread_db-0.9.33.2.so
line to your configuration file "/root/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/root/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.

Program received signal SIGILL, Illegal instruction.
0x00c79008 in v8::base::CPU::CPU() ()
(gdb) disassemble $pc,$pc+32
Dump of assembler code from 0xc79008 to 0xc79028:
=> 0x00c79008 <_ZN2v84base3CPUC2Ev+308>: ldc1 $f0,32(s8)
0x00c7900c <_ZN2v84base3CPUC2Ev+312>: mtc1 t0,$f1
0x00c79010 <_ZN2v84base3CPUC2Ev+316>: sdc1 $f0,32(s8)
0x00c79014 <_ZN2v84base3CPUC2Ev+320>: lui v0,0xc8
0x00c79018 <_ZN2v84base3CPUC2Ev+324>: lw a0,32(s8)
0x00c7901c <_ZN2v84base3CPUC2Ev+328>: lw a1,36(s8)
0x00c79020 <_ZN2v84base3CPUC2Ev+332>: lw a2,21216(v0)
0x00c79024 <_ZN2v84base3CPUC2Ev+336>: jal 0xe25c30 __nedf2@plt
End of assembler dump.

@Nicholasny
Copy link
Author

root@OpenWrt:/usr/bin# ldd node
libdl.so.0 => /lib/libdl.so.0 (0x7702c000)
librt.so.0 => /lib/librt.so.0 (0x77018000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x76f30000)
libm.so.0 => /lib/libm.so.0 (0x76f0a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x76ee6000)
libpthread.so.0 => /lib/libpthread.so.0 (0x76ec0000)
libc.so.0 => /lib/libc.so.0 (0x76e54000)
ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x77040000)

root@OpenWrt:/usr/bin# node -v
v4.1.2

@mscdex
Copy link
Contributor

mscdex commented Jan 23, 2016

Are you sure the kernel has FPU emulation compiled in? Does dmesg | grep -i fpu show anything? I believe it should show something like "Algorithmics/MIPS FPU Emulator" if FPU emulation is in fact enabled in the kernel.

@Nicholasny
Copy link
Author

dmesg | grep -i fpu
no any output!
How to enable soft fpu in Openwrt 15.05?
I have select software floating piont in Openwrt, see below:
Advanced configuration options (for developers)->Target Options->[*] Use software floating point by default

@mscdex
Copy link
Contributor

mscdex commented Jan 23, 2016

After make menuconfig, you should be able to do make kernel_menuconfig and select the Enable FPU emulation option as shown here.

@Nicholasny
Copy link
Author

thanks a lot!!!!! but dmesg | grep -i fpu still no any output!!

@tpham3783
Copy link

I am sorry, does the app still crash after enabling software fpu?

@enzomich
Copy link

enzomich commented Dec 26, 2016

From what I understand, floating point emulation on MIPS platforms was disabled several years ago: https://lists.openwrt.org/pipermail/openwrt-devel/2009-June/004562.html , So, node.js should be compiled with floating point emulation support - but, apparently, it is not. I have this same issue with CC 15.05.1 on a TP-LINK TL-WR1043ND v3 (CPU MIPS 74Kc V5.0): the binary package for Node downloaded from https://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/packages/node_v0.12.7-1_ar71xx.ipk crashes on a FP instruction (swc1):

Program received signal SIGILL, Illegal instruction.
0x57e2cc10 in ?? ()
(gdb) disassemble $pc,$pc+32
Dump of assembler code from 0x57e2cc10 to 0x57e2cc30:
=> 0x57e2cc10: swc1 $f30,44(sp)
0x57e2cc14: swc1 $f31,40(sp)
0x57e2cc18: swc1 $f28,36(sp)
0x57e2cc1c: swc1 $f29,32(sp)
0x57e2cc20: swc1 $f26,28(sp)
0x57e2cc24: swc1 $f27,24(sp)
0x57e2cc28: swc1 $f24,20(sp)
0x57e2cc2c: swc1 $f25,16(sp)
End of assembler dump.

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. mips Issues and PRs related to the MIPS architecture.
Projects
None yet
Development

No branches or pull requests

5 participants