nodejs/help

node: ../deps/uv/src/unix/core.c:544: uv__close_nocheckstdio: Assertion `fd > -1' failed.

Closed this issue · 12 comments

gwmai commented
  • Node.js Version:v12.3.1
  • OS: Ubuntu 18.0.4
  • Scope (install, code, runtime, meta, other?): Trying to install packages
  • Module (and version) (if relevant): Any module

I'm trying to use npm install @symfony/webpack-encore and I'm getting the following error

This works OK when I run as root but when doing from a chrooted user it yields this error. Probably some library is missing in the chroot environment but I'm unable to deduce from the error message.

node: ../deps/uv/src/unix/core.c:544: uv__close_nocheckstdio: Assertion `fd > -1' failed.
Aborted (core dumped)

Can you share a core dump, and/or try to use the latest version of Node 12 and see if it still reproduces?

Same thing on 12.7 version. How would I take a core dump in chroot environment?

After thorough debugging this error came from missing /sys/fs/cgroup/memory/memory.limit_in_bytes and /proc/meminfo files in chroot environment.

@nodejs/libuv @kjin

I believe libuv/libuv#2323 addresses this.

kjin commented

I'm still looking into it, but I should note that my change(s) do not have to do with reading /proc/meminfo, and currently I can't see a code path that would lead to fd failing the assertion check. Not to say that this isn't because of the cgroups change, but because uv_get_total_memory has existed before the cgroups change, I'm curious as to whether this was failing before v12.3.1 (right now, to me, it would be strange if it didn't).

I have two servers running debian 8 and 9 with node 10.x and 11.x and I didn't face this issue. In ubuntu however all node versions from 10+ threw this error

$ node
node: src/unix/core.c:556: uv__close_nocheckstdio: Assertion `fd > -1' failed.
Aborted
$ node -v
v13.6.0

strace:

[pid 1276004] openat(AT_FDCWD, "/sys/fs/cgroup/memory/memory.limit_in_bytes", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 1276004] openat(AT_FDCWD, "/proc/meminfo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 1276004] read(-2, 0x7fffdd4b45a0, 4095) = -1 EBADF (Bad file descriptor)
[pid 1276004] write(2, "node: src/unix/core.c:556: uv__c"..., 79node: src/unix/core.c:556: uv__close_nocheckstdio: Assertion `fd > -1' failed.

It is libuv issue in uv_get_total_memory (checked with libuv 1.34.0):

#3  0x00007ffff71810a2 in __GI___assert_fail (assertion=assertion@entry=0x7ffff7f9f8fd "fd > -1", file=file@entry=0x7ffff7f9f8d5 "src/unix/core.c", line=line@entry=556, 
    function=function@entry=0x7ffff7f9fb50 <__PRETTY_FUNCTION__.10400> "uv__close_nocheckstdio") at assert.c:101
#4  0x00007ffff7f8b8f3 in uv__close_nocheckstdio (fd=-2) at src/unix/core.c:556
#5  uv__close_nocheckstdio (fd=fd@entry=-2) at src/unix/core.c:552
#6  0x00007ffff7f9abc1 in uv__read_proc_meminfo (what=0x7ffff7fa0e54 "MemTotal:") at src/unix/linux-core.c:1006
#7  0x00007ffff7f9c012 in uv_get_total_memory () at src/unix/linux-core.c:1033
#8  0x0000000000a0d355 in node::SetIsolateCreateParamsForNode (params=params@entry=0x7fffffffe430) at ../src/api/environment.cc:191

@vitlav Thanks, that’s very helpful. libuv/libuv#2645 should address this 👍

@vitlav Thanks, that’s very helpful. libuv/libuv#2645 should address this
Thank you very much! node works with this fix ever if /proc is missed.

apusg commented

In which release will this change be included?