Node: Crash with "Unknown signal 33" when calling process.setuid() under qemu-arm

Created on 24 Mar 2017  路  6Comments  路  Source: nodejs/node

I am creating a debootstrap --foreign chroot for armhf from an x86_64 host. Inside which binfmt-misc + qemu-arm is used to run the arm binaries, including nodejs. (This is a standard procedure for creating a debian distro for ARM target.) My goal is to install nodejs along with some dependencies (a whole application, actually) on the rootfs.

After installing nodejs in the target chroot I call npm i -g [email protected] and nodejs crashes.

I've tracked it down to uid-number doing the following:

# cat get-uid-gid.js 
var user = process.getuid()
  , group = process.getgid()

process.setgid(group)
process.setuid(user)

This results in:

# node get-uid-gid.js
Unknown signal 33

(just doing process.setuid or process.setgid is enough to trigger it.)

Everything else works fine in this environment, including npm i without the -g flag, presumably because npm is not attempting to check UID/GID before installing.

I'm not sure how to dive further into this but I'm happy to provide more info if requested.

I've also reported the issue at npm/uid-number#6 although it seems clear the issue is not in uid-number itself.

# node --version
v6.9.5

# uname -a   # inside chroot
Linux 52b1175d907b 4.9.12-moby #1 SMP Tue Feb 28 12:11:36 UTC 2017 armv7l GNU/Linux

# uname -a   # outside chroot
Linux 52b1175d907b 4.9.12-moby #1 SMP Tue Feb 28 12:11:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

# file build/rootfs/usr/bin/nodejs
build/rootfs/usr/bin/nodejs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=02600891d13f139aad4131f4b9bc0576a5be4641, stripped

Worth noting that the Linux host is itself a Docker container running on a Mac OSX host :) But hopefully the problem does not go down that many levels of inception :D

arm process

Most helpful comment

@thom-nic Interesting. Just fixed(?) it maybe myself. Toggling npm config set unsafe-perm true/false before/after installing any global modules during my qemu-user-static building script works for me now. Thanks for the reply, was close to doing something similar myself. The install ends with this error block, but everything seems to work.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/XXXXXX/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

This same block appears for all global modules I have attempted to install with unsafe-perm enabled so not sure if is related or coincidence.

All 6 comments

You probably need to look beyond node. Signal 33 is SIGSETXID, which is what nptl (glibc's pthreads library) uses to communicate between threads. Among other things it's used to propagate setgid() and setuid() changes across threads.

Thanks Ben. I'll dig a little deeper and see if there's some mismatch that I can identify.

Any updates on this @thom-nic ? I am running into the exact issue in the exact envirotonment you describe... Mac -> Docker -> qemu-arm-static

Like you, I can npm install, but can not do so with -g. Curious if you made any discoveries / workarounds.

TIA

@nmarus actually I solved my issue by avoiding npm i altogether 馃槀 Instead I prebuilt the entire app + node_modules deps and put it into a .deb. However this reminds me of a similar issue that I ran into: #12537

I would try running on Ubuntu Zesty host which has qemu-user-static 2.8 or search the qemu bug tracker for setuid.

@thom-nic Interesting. Just fixed(?) it maybe myself. Toggling npm config set unsafe-perm true/false before/after installing any global modules during my qemu-user-static building script works for me now. Thanks for the reply, was close to doing something similar myself. The install ends with this error block, but everything seems to work.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/XXXXXX/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

This same block appears for all global modules I have attempted to install with unsafe-perm enabled so not sure if is related or coincidence.

You can ignore the warning, fsevents is an OS X-only module. I'll go ahead and close out the issue, seeing how it isn't a node bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevenvachon picture stevenvachon  路  3Comments

dfahlander picture dfahlander  路  3Comments

cong88 picture cong88  路  3Comments

mcollina picture mcollina  路  3Comments

srl295 picture srl295  路  3Comments