Termux-packages: Segmentation fault with npm

Created on 20 Apr 2020  路  20Comments  路  Source: termux/termux-packages

Problem description

Segmentation fault when running npm. It worked with nodejs 13.0.0-3, but the latest update to 13.13.0 broke it. It seems that node still works:

// index.js
console.log("Hello");

```console
$ node index.js
Hello

**Steps to reproduce**
<!--
Steps to reproduce the behavior. Please post all necessary
commands that are needed to reproduce the issue.
-->
```console
$ npm --version
Segmentation fault

Expected behavior

Shouldn't segfault.

Additional information

Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.org/packages/ stable main
# game-repo (sources.list.d/game.list)
deb https://dl.bintray.com/grimler/game-packages-24 games stable
# science-repo (sources.list.d/science.list)
deb https://dl.bintray.com/grimler/science-packages-24 science stable
# unstable-repo (sources.list.d/unstable.list)
deb https://dl.bintray.com/xeffyr/unstable-packages unstable main
Updatable packages:
All packages up to date
Android version:
10
Kernel build information:
Linux localhost 4.14.117-perf #1 SMP PREEMPT Tue Jan 28 17:26:17 KST 2020 aarch64 Android
Device manufacturer:
LGE
Device model:
LM-G820
bug report

Most helpful comment

https://github.com/termux/termux-packages/commit/1435b6ff9b6a0b7a2380b36a048e3ada0f09548b fixes the issue.

Updated node v13 package will be available soon. Will also apply patch for nodejs-lts.

All 20 comments

I can reproduce the segfault also with a debug build, but if I try to run it under gdb it does not segfault (but exits with an error without outputting anything).

Debug build available here: https://grimler.se/dists/testing/debug/binary-aarch64/nodejs-dbg_13.13.0_aarch64.deb

nodejs-lts gives segfault with yarn too: https://github.com/termux/termux-packages/issues/5141.

Debug build fails during compilation time, so I can't get stacktrace currently.

Debug build fails during compilation time, so I can't get stacktrace currently.

Debug build of nodejs-lts? What error did you get? I managed to build debug of both versions without errors (I was not building in the docker image, maybe that's why)

@Grimler91 I have built it now, just first time I got undefined references at linking for some reason.

Backtrace for lts version is here: https://github.com/termux/termux-packages/issues/5141#issuecomment-616559729

Backtrace for v13.13.0:

(gdb) bt
#0  addToEnd (p_resultList=<optimized out>, p_entry=0x7fb507a370) at ../deps/uv/src/unix/android-ifaddrs.c:316
#1  0x0000005556e11d70 in interpretAddr (p_hdr=<optimized out>, p_resultList=0x7fffffd0d0, p_numLinks=<optimized out>) at ../deps/uv/src/unix/android-ifaddrs.c:587
#2  0x0000005556e113a8 in interpretAddrs (p_socket=21, p_pid=2923, p_netlinkList=0x7fb0fdc2a0, p_resultList=0x7fffffd0d0, p_numLinks=15)
    at ../deps/uv/src/unix/android-ifaddrs.c:644
#3  0x0000005556e10ff0 in getifaddrs (ifap=0x7fffffd0d0) at ../deps/uv/src/unix/android-ifaddrs.c:692
#4  0x0000005556e0f8a0 in uv_interface_addresses (addresses=0x7fffffd170, count=0x7fffffd16c) at ../deps/uv/src/unix/linux-core.c:890
#5  0x0000005556338f10 in node::os::GetInterfaceAddresses (args=...) at ../src/node_os.cc:179
#6  0x00000055564f62f4 in v8::internal::FunctionCallbackArguments::Call (this=0x7fffffd360, handler=...) at ../deps/v8/src/api/api-arguments-inl.h:158
#7  0x00000055564f56c0 in v8::internal::(anonymous namespace)::HandleApiCallHelper<false> (isolate=0x7fb508b040, function=..., new_target=..., fun_data=..., receiver=..., 
    args=...) at ../deps/v8/src/builtins/builtins-api.cc:111
#8  0x00000055564f48ac in v8::internal::Builtin_Impl_HandleApiCall (args=..., isolate=0x7fb508b040) at ../deps/v8/src/builtins/builtins-api.cc:141
#9  0x00000055564f4514 in v8::internal::Builtin_HandleApiCall (args_length=6, args_object=0x7fffffd578, isolate=0x7fb508b040) at ../deps/v8/src/builtins/builtins-api.cc:129
#10 0x00000055571a6c0c in Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) q
A debugging session is active.

    Inferior 1 [process 2923] will be killed.

Quit anyway? (y or n) y
$ node --version
v13.13.0

- same as in case of nodejs-lts.


Easiest way to crash nodejs is to execute os.networkInterfaces():

$ node
Welcome to Node.js v13.13.0.
Type ".help" for more information.
> os.networkInterfaces()
Segmentation fault

UPD: this is not reliable way to reproduce crash.

@ParseThisCode is that on arm or aarch64?

I also tried npm under termux-chroot and it works without segfault

Thanks , it worked

Can confirm this issue, but I don't know how to use with pnpm and termux-chroot

Can confirm the npm issue on armv8l Android 9. However the os.networkInterfaces(); work fine, i don't know how to try chroot termux-chroot npm --version terminates with weird signals and stuff.

However the os.networkInterfaces(); work fine

Interesting that it started to work for me once I have enabled & disabled mobile networking.

Yarn still crashes, with same trace as in https://github.com/termux/termux-packages/issues/5177#issuecomment-616565943.

termux-chroot doesn't fix anything.

Perhaps this is a bug in libuv dependency. We use one supplied with Nodejs source, so it may be a bit outdated. Seems to be fixed in https://github.com/libuv/libuv/commit/7656e981b6633635e72bacc447bc6d3ab88ce0cd.

I've compiled libuv 1.37.0 under termux. How make it work with Nodejs?

How make it work with Nodejs?

Our nodejs build uses internal statically-linked libuv. You can't replace it in runtime.

https://github.com/termux/termux-packages/commit/1435b6ff9b6a0b7a2380b36a048e3ada0f09548b fixes the issue.

Updated node v13 package will be available soon. Will also apply patch for nodejs-lts.

Indeed. I started getting this error, searched, found this, updated nodejs to 13.13.0-2, and now I'm not getting it. NPM working correctly.

Same Problem with Nodejs 14.0

@creppu npm is crashing for you ? What command you have executed to get a crash ?

npm install <package> works for me without any issue.

Okay sry, my mistake.
It crashed on an old Samsung S3 mini with Android 7.2.1.
Steps to reproduce:

$ npm --version
Segmentation fault

I belive the phone can now go to the trash...
I try it on an other phone (S4 Android 9) and there is everyting working like expected.

Was looking for a resolution at the end of the answers but that last message did let me down.
I've recently installed termux on S3 Mini after having to installing Android 7.2.1 because no other previous version of android is compatile with Termux anymore.
My main purpose is to install node-red and using termux-api in this device for a Robotic project using all the hardware it has available, 7.2.1 works great so far. Is there anything I can do to be able to run npm? I dont get why it doesnt work here (dualcore A9, is there any incompatibility with it?) RAM perhaps? Thank you

Is there anything I can do to be able to run npm?

@januxnet I can't get any segfault with npm with latest nodejs and nodejs-lts packages.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thurask picture thurask  路  3Comments

reggi picture reggi  路  4Comments

Wetitpig picture Wetitpig  路  3Comments

divyakutty picture divyakutty  路  3Comments

Zuccace picture Zuccace  路  3Comments