Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Bug in "Date" object #1131

Closed
jampy opened this issue May 31, 2011 · 14 comments
Closed

Bug in "Date" object #1131

jampy opened this issue May 31, 2011 · 14 comments

Comments

@jampy
Copy link

jampy commented May 31, 2011

With Node 0.4.8 cross-compiled for ARM I get the following output:

> new Date()
Tue, 31 May 2011 13:53:50 GMT
> new Date()
undefined, 31 May 2011 07.193226e-317:01.85920713e-315:51 GMT
> new Date()
undefined, 31 May 2011 07.193226e-317:01.85920713e-315:52 GMT
> new Date().toString();
'undefined May 31 2011 07.193226e-317:04.55897533e-316:15 GMT+0000 (UTC)'

...meaning that the first Date object prints a valid timestamp and all consecutive calls of the same command print a silly string.
I tried numerous times and it always shows the same effect. Same thing when using .toString().

Converting to milliseconds works, however:

> new Date()*1;
1306850269381

Kernel: 2.6.26.7

@jampy
Copy link
Author

jampy commented May 31, 2011

FYI, I had to add

conf.define('HAVE_CLOCK_SYSCALL', 1)

to deps/libev/wscript to make Node cross-compile (as described on http://fastr.github.com/articles/cross-compiling-node.js-for-arm.html, but I only patched deps/libev/wscript, not wscript from the Node base directory).
Maybe that's related...

@bnoordhuis
Copy link
Member

Does this still happen with 0.4.10? It's a V8 bug that I'm 95% sure has been fixed.

@jampy jampy closed this as completed Aug 16, 2011
@jampy jampy reopened this Aug 16, 2011
@jampy
Copy link
Author

jampy commented Aug 16, 2011

./configure still needs a manual patch and I'm unable to build 0.4.10:

Waf: Entering directory `/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/build'
DEST_OS: linux
DEST_CPU: arm
Parallel Jobs: 1
Product type: program
[51/74] libv8.a: deps/v8/SConstruct -> build/default/libv8.a
/usr/bin/python "/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/tools/scons/scons.py" -j 1 -C "/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/build/default/" -Y "/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/deps/v8" visibility=default mode=release arch=arm toolchain=gcc library=static snapshot=on
scons: Reading SConscript files ...

scons: warning: Ignoring missing SConscript 'obj/test/release/SConscript'
File "/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/deps/v8/SConstruct", line 1201, in BuildSpecific
scons: done reading SConscript files.
scons: Building targets ...
obj/release/mksnapshot obj/release/snapshot.cc --logfile "/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/build/default/obj/release/snapshot.log" --log-snapshot-positions
/bin/bash: obj/release/mksnapshot: cannot execute binary file
scons: *** [obj/release/snapshot.cc] Error 126
scons: building terminated because of errors.
Waf: Leaving directory `/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/build'
Build failed:  -> task failed (err #2):
        {task: libv8.a SConstruct -> libv8.a}
make: *** [program] Error 1

@sh1mmer
Copy link

sh1mmer commented Nov 2, 2011

@jampy could you submit a pull request with the patch for configure and try building with HEAD which includes a newer build of V8.

Thanks

@bnoordhuis
Copy link
Member

@sh1mmer: The configure patch was merged in ed44098.

Closing the issue, master on ARM doesn't exhibit this bug (and if it does, it should be forwarded to the V8 guys anyway - Date is a V8 object).

@ed-davies
Copy link

bnoordhuis asked: "Does this still happen with 0.4.10?".

Yes:

Linux penelope 2.6.32-5-kirkwood #1 Tue Jun 14 23:05:32 UTC 2011 armv5tel
...
edavies@penelope:$ node --version
v0.4.10
edavies@penelope:
$ node

new Date()
Thu, 24 Nov 2011 10:47:39 GMT
new Date()
undefined, 24 Nov 2011 07.2016155e-317:03.929525897e-315:42 GMT

That's a locally compiled version of nodejs built following the hint given at:

http://stackoverflow.com/questions/6788768/cannot-build-node-on-sheevaplug-armv5t-with-debian-squeeze#answer-6790823

@bnoordhuis
Copy link
Member

@ed-davies: v0.4.10 ships with V8 3.1.8. That's ancient history by now. Upgrade to v0.6.2, it bundles V8 3.6.6.8.

@ed-davies
Copy link

Indeed. But somebody coming across this thread might find it useful information that v0.4.10 doesn't fix the problem.

Compiling a new version is enough of a pain that people are not likely to do it unless they have a specific reason. v0.6.2 doesn't compile to something sensible for me, for example:

Patched SConfigure as per previous versions:

 $ diff node-v0.6.2/deps/v8/SConstruct ../node-v0.6.2/deps/v8/SConstruct 
 82c82
 <       'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS'],
 ---
 >       'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv5t'],

$ ./configure
$ make

Compile errors to do with snapshot.cc or so. Google google.

$ make clean
$ ./configure --without-snapshot
$ make

Complies again, apparently clean, but:

$ ./node
Illegal instruction

Google, google. Apparently I'm not alone but I didn't see a coherent answer.

@bnoordhuis
Copy link
Member

I bet you a sixpack that you need to compile with -mfloat-abi=soft.

The number 1 reason for mksnapshot crashing or Node dying with a SIGILL is that people compile with floating point enabled for a CPU that doesn't have an floating point unit. grep fpu /proc/cpuinfo will probably confirm that.

@ed-davies
Copy link

Sorry, no sixpack yet. /proc/cpuinfo indeed has no "fpu" string. Doesn't have a "flags:" line at all, in fact:

$ cat /proc/cpuinfo 
Processor   : Feroceon 88FR131 rev 1 (v5l)
BogoMIPS    : 1192.75
Features    : swp half thumb fastmult edsp 
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant : 0x2
CPU part    : 0x131
CPU revision    : 1

Hardware    : Marvell SheevaPlug Reference Board
Revision    : 0000
Serial      : 0000000000000000

Just to check, a bit more context around my change to SConstruct:

$ diff -c node-v0.6.2/deps/v8/SConstruct ../node-v0.6.2/deps/v8/SConstruct 
*** node-v0.6.2/deps/v8/SConstruct  2011-11-18 22:43:03.000000000 +0000
--- ../node-v0.6.2/deps/v8/SConstruct   2011-11-26 16:46:00.000000000 +0000
***************
*** 79,85 ****
    },
    'gcc': {
      'all': {
!       'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS'],
        'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions'],
      },
      'visibility:hidden': {
--- 79,85 ----
    },
    'gcc': {
      'all': {
!       'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv5t', '-mfloat-abi=soft'],
        'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions'],
      },
      'visibility:hidden': {

Might issue #2131 be a better place to discuss this?

@bnoordhuis
Copy link
Member

Sure. Keep in mind that you need to compile all of Node (not just V8) with -march=armv5t -mfloat-abi=soft

@konobi
Copy link

konobi commented Nov 27, 2011

Just got node compiled on armv5tel myself... I also have to add -fno-tree-sink to CCFLAGS

NB: the requirements for the float abi stuff is required for older ARM versions. The newer ARMs (armv7-a etc.) have vpu support.

See http://code.google.com/p/v8/wiki/CrossCompilingForARM for more info.

Also see #883

@ed-davies
Copy link

I did a binary chop on Node versions using the equivalent of:

tar xvzf ../node-<version>.tar.gz
cd node-<version>
export CCFLAGS="-march=armv5t -mfloat-abi=soft -fno-tree-sink"
./configure --without-snapshot
make
./node --version
./node
new Date()
new Date()

Versions up to and including 0.5.0 exhibit the Date bug. Version 0.5.1 and beyond give "Illegal instruction". Sadly, there seems to be no happy medium where Date works and compilation is possible with what I know.

@ed-davies
Copy link

Possible workaround, put:

new Date().setHours(0);

early in the code and the problem seems to disappear, at least for a while.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants