Julia: Julia fails to run _before_ epoch

Created on 9 Dec 2019  路  10Comments  路  Source: JuliaLang/julia

Julia crashes on start when time is 0 (1970-01-01):

faketime "1970-01-01" julia

fatal: error thrown and no exception handler available.
#<null>
rec_backtrace at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/stackwalk.c:94
record_backtrace at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/task.c:217 [inlined]
jl_throw at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/task.c:417
Type at ./float.jl:682 [inlined]
convert at ./number.jl:7 [inlined]
cconvert at ./essentials.jl:355 [inlined]
srand at ./libc.jl:384 [inlined]
srand at ./libc.jl:384 [inlined]
__init__ at ./sysimg.jl:489
jl_apply_generic at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/gf.c:2197
jl_apply at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/julia.h:1571 [inlined]
jl_module_run_initializer at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/toplevel.c:72
_julia_init at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/init.c:832
unknown function (ip: 0x402307)
__libc_start_main at /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib/libc.so.6 (unknown line)
unknown function (ip: 0x4023b9)
nixo@guixSD ~/git/guix-julia-dev [env]$ faketime "1970-01-01" julia
fatal: error thrown and no exception handler available.
#<null>
rec_backtrace at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/stackwalk.c:94
record_backtrace at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/task.c:217 [inlined]
jl_throw at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/task.c:417
Type at ./float.jl:682 [inlined]
convert at ./number.jl:7 [inlined]
cconvert at ./essentials.jl:355 [inlined]
srand at ./libc.jl:384 [inlined]
srand at ./libc.jl:384 [inlined]
__init__ at ./sysimg.jl:489
jl_apply_generic at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/gf.c:2197
jl_apply at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/julia.h:1571 [inlined]
jl_module_run_initializer at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/toplevel.c:72
_julia_init at /tmp/guix-build-julia-1.1.1.drv-0/julia-1.1.1/src/init.c:832
unknown function (ip: 0x402307)
__libc_start_main at /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib/libc.so.6 (unknown line)
unknown function (ip: 0x4023b9)

(faketime 1970-01-02) does work

versioninfo()
Commit 55e36cc308 (2019-05-16 04:10 UTC)
Platform Info:
  OS: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Core(TM)2 CPU         P8600  @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, penryn)
Environment:
bug help wanted

All 10 comments

Maybe there's a locale problem?

faketime -f '1970-01-01 01:00:00' julia -E 'time()'
0.0

I can confirm it's the locale. I'll close this in a few hours if nobody think that the error should be addressed

Julia should crash even if the locale is set to something weird. Can you give more reproduction details?

(with locale I meant time zone, date: Mon 09 Dec 2019 05:21:45 PM CET)

faketime -f '1970-01-01 00:00:00' julia -E 'time()' -> error in the OP
faketime -f '1970-01-01 00:59:00' julia -E 'time()' -> error in the OP
faketime -f '1970-01-01 01:00:00' julia -E 'time()' -> 0.0
TZ="London" faketime -f '1970-01-01 00:00:00' julia -E 'time()' -> 0.0

So: julia does not like time before the epoch (negative time?).

However, date does work (NOTE: 1900)
faketime -f '1900-01-01 00:00:00' date

Mon 01 Jan 1900 12:00:00 AM CET

Also, it will become unusable in less than 100years from now (2106-02-07).

That means either that The 100 was lying or the bug will be fixed :rofl:

Yep, that's why I linked it :confused:

The issue is in libc.jl in the line:

srand(seed=floor(time())) = ccall(:srand, Cvoid, (Cuint,), seed)

Before the epoch, floor(time()) would be a negative value, but C's srand() takes an unsigned int.

Thanks, I did not have time to try it. Does it fix also the opposite (from date 2106-02-07 on)?

Yes, the opposite will also work.

$ faketime "10000-01-01 00:00:00" ./julia -E 'time()'
2.5340231880103674e11
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yurivish picture yurivish  路  3Comments

sbromberger picture sbromberger  路  3Comments

m-j-w picture m-j-w  路  3Comments

i-apellaniz picture i-apellaniz  路  3Comments

tkoolen picture tkoolen  路  3Comments