mailing list of musl libc
 help / color / mirror / code / Atom feed
* Bug on fstat()?
@ 2014-08-24 20:51 piranna
  2014-08-24 21:05 ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: piranna @ 2014-08-24 20:51 UTC (permalink / raw)
  To: musl

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:

#!./node
while(true)
{
  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:

fs.js:505
  var r = binding.read(fd, 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
/usr/include/i386-linux-musl/linux
    sudo ln -s /usr/include/i386-linux-gnu/asm /usr/include/i386-linux-musl/asm
    sudo ln -s /usr/include/asm-generic
/usr/include/i386-linux-musl/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
Unix."
– Linus Tordvals, creador del sistema operativo Linux


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-08-26 19:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-24 20:51 Bug on fstat()? piranna
2014-08-24 21:05 ` Rich Felker
2014-08-24 21:23   ` piranna
2014-08-24 21:35     ` Luca Barbato
2014-08-25  9:18       ` piranna
2014-08-25  9:31         ` piranna
2014-08-25  9:49           ` Szabolcs Nagy
2014-08-25 15:48             ` Rich Felker
2014-08-26 19:05               ` piranna

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).