From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5887 Path: news.gmane.org!not-for-mail From: "piranna@gmail.com" Newsgroups: gmane.linux.lib.musl.general Subject: Bug on fstat()? Date: Sun, 24 Aug 2014 22:51:09 +0200 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1408913546 27911 80.91.229.3 (24 Aug 2014 20:52:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 24 Aug 2014 20:52:26 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5893-gllmg-musl=m.gmane.org@lists.openwall.com Sun Aug 24 22:52:18 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XLelt-0004AA-TI for gllmg-musl@plane.gmane.org; Sun, 24 Aug 2014 22:52:17 +0200 Original-Received: (qmail 32760 invoked by uid 550); 24 Aug 2014 20:51:41 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 32737 invoked from network); 24 Aug 2014 20:51:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=Qf0AET5tcuxowxrYvu/STxdJa07H7q8rTZ/8sVz3D8s=; b=ZKRwx0I/2+m5l5Wl6qgCPkKyq7fud0xumkRFDsGoOQlsMe/RjC/hD91vl+QuQaAJ1k 4HzoPzqdkeZoeAQNoXISzt47v2GDZjIOAeoKHJUmHKSCKf3iQJXp9OgDukJjD8BPDHep UN+U1gqMGhQXvRLBJtuU/KHdMj/BfcVVMTd2JOFnp03XAZjVvfYcVIx1gZyB7yVg+D2g EYRLiASl32i6cJi7C63qLhXMkWgY8MQWIZBJ+U4ra5waKi86p9rar0CyIoLByliCLi+N kekMCjXpB2QjJQobEkA5EuEenJa4yZLcVkrliCGixVI7Eg6LuVr1bRinObySDOq2Pyot xoBA== X-Received: by 10.195.11.200 with SMTP id ek8mr4647079wjd.85.1408913489644; Sun, 24 Aug 2014 13:51:29 -0700 (PDT) Xref: news.gmane.org gmane.linux.lib.musl.general:5887 Archived-At: 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 =3D 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? --=20 "Si quieres viajar alrededor del mundo y ser invitado a hablar en un monton de sitios diferentes, simplemente escribe un sistema operativo Unix." =E2=80=93 Linus Tordvals, creador del sistema operativo Linux