Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 24 Aug 2014 22:51:09 +0200
From: "" <>
Subject: Bug on fstat()?

I have been able to compile Node.js using musl to create a fully
statically linked executable (SSL disabled, OpenSSL was giving too
much problems...), and although Node.js REPL works, it can't be able
to load script files.

Digging on the code I have got to the point that Node.js do a fstat()
call to know the size of the script file so it can fill a buffer of
the correct size, problem is that fstat() is giving me some crazy
values. I did the same before using glibc and it was able to load
simple script files, so seems to be a problem related to musl (or the
environment I've crafted to be able to compile Node.js using musl).

The simple test file is:

  console.log('Hello NodeOS! :-)')

./node is the musl-compiled static Node.js executable. Executing this
file from console give me the next error, the same error is thrown by
dispatching it as parameter of the Node.js executable:

  var r =, buffer, offset, length, position);
Error: Offset is out of bounds
    at Error (native)
    at Object.fs.readSync (fs.js:505:19)
    at Object.fs.readFileSync (fs.js:346:28)
    at Object.Module._extensions..js (module.js:477:20)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:124:16)
    at node.js:811:3

The values that fstat() is returning are:

{ dev: 2051,
  mode: 33261,
  nlink: 1,
  uid: 1000,
  gid: 1000,
  rdev: 0,
  blksize: 8,
  ino: 584753551390482400,
  size: 17592186044477,
  blocks: 1485010404567043000,
  atime: Sun Aug 24 2014 22:33:06 GMT+0200 (CEST),
  mtime: Sun Aug 24 2014 22:33:06 GMT+0200 (CEST),
  ctime: Thu Jan 01 1970 01:00:00 GMT+0100 (CET),
  birthtime: Thu Jan 01 1970 01:00:00 GMT+0100 (CET) }

As you can see, is giving a size of 164GBs for a file of just 68
characters :-) ino, blocks and blksize have some strange values too,
but the other fields seems to be normal. As I told you, fstat() give a
correct output while compiling Node.js with glibc.

I'm using musl with the musl-gcc wrapper, and since it was giving me
problems related to some includes not available, I've done some (not
very clean, I know) symbolic links to them:

    sudo ln -s /usr/include/linux
    sudo ln -s /usr/include/i386-linux-gnu/asm /usr/include/i386-linux-musl/asm
    sudo ln -s /usr/include/asm-generic

Any advice about what could be happening? How could I be able to solve it?

"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
– Linus Tordvals, creador del sistema operativo Linux

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.