Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia fails to run _before_ epoch #34056

Closed
nico202 opened this issue Dec 9, 2019 · 10 comments · Fixed by #34442
Closed

Julia fails to run _before_ epoch #34056

nico202 opened this issue Dec 9, 2019 · 10 comments · Fixed by #34442
Labels
bug Indicates an unexpected problem or unintended behavior help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@nico202
Copy link
Contributor

nico202 commented Dec 9, 2019

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:
@nico202
Copy link
Contributor Author

nico202 commented Dec 9, 2019

Maybe there's a locale problem?

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

@nico202
Copy link
Contributor Author

nico202 commented Dec 9, 2019

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

@nico202 nico202 closed this as completed Dec 9, 2019
@StefanKarpinski
Copy link
Member

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

@nico202
Copy link
Contributor Author

nico202 commented Dec 9, 2019

(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

@nico202 nico202 changed the title Julia fails to run on epoch Julia fails to run _before_ epoch Dec 9, 2019
@StefanKarpinski StefanKarpinski added bug Indicates an unexpected problem or unintended behavior help wanted Indicates that a maintainer wants help on an issue or pull request labels Dec 9, 2019
@nico202
Copy link
Contributor Author

nico202 commented Dec 9, 2019

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 🤣

@ViralBShah
Copy link
Member

@nico202
Copy link
Contributor Author

nico202 commented Dec 9, 2019

Yep, that's why I linked it 😕

@anaveragehuman
Copy link
Contributor

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.

@nico202
Copy link
Contributor Author

nico202 commented Jan 21, 2020

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

@anaveragehuman
Copy link
Contributor

Yes, the opposite will also work.

$ faketime "10000-01-01 00:00:00" ./julia -E 'time()'
2.5340231880103674e11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants