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

erfc(::BigFloat) crashes Julia #127

Closed
dlichtistw opened this issue Oct 25, 2018 · 11 comments
Closed

erfc(::BigFloat) crashes Julia #127

dlichtistw opened this issue Oct 25, 2018 · 11 comments

Comments

@dlichtistw
Copy link

dlichtistw commented Oct 25, 2018

Julia 0.7 crashes whenever I call SpecialFunctions.erfc with a BigInt or BigFloat value near 30. For example erfc(big"26.5") and erfc(big"32.0") are ok, but erfc(big"27.0") and erfc(big"31.5") will fail. BigInts in that range will also fail, but the corresponding Float64 and Int64 will succeed.

I am using SpecialFunctions v0.7.1 on Julia 0.7.

julia> erfc(big"30.5");
/buildworker/worker/package_linux64/build/deps/srccache/mpfr-4.0.1/src/uceil_log2.c:40: MPFR assertion failed: exp < 1023

signal (6): Aborted
in expression starting at no file:0
__libc_signal_restore_set at /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/nptl-signals.h:80 [inlined]
raise at /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:48
abort at /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:79
mpfr_assert_fail at /buildworker/worker/package_linux64/build/deps/srccache/mpfr-4.0.1/src/mpfr-gmp.c:300
__gmpfr_ceil_log2 at /buildworker/worker/package_linux64/build/deps/srccache/mpfr-4.0.1/src/uceil_log2.c:40
mpfr_erf at /buildworker/worker/package_linux64/build/deps/srccache/mpfr-4.0.1/src/erf.c:240
mpfr_erfc at /buildworker/worker/package_linux64/build/deps/srccache/mpfr-4.0.1/src/erfc.c:251
erfc at /home/lichti/.julia/packages/SpecialFunctions/sXbz6/src/erf.jl:15
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:324
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:428
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:363 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:686
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:799
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f98dddd9f4f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:808
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:831
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/builtins.c:633
eval at ./boot.jl:319
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:85
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:262
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1538 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
Allocations: 735907 (Pool: 735629; Big: 278); GC: 0
Aborted (core dumped)
@stevengj
Copy link
Member

stevengj commented Oct 25, 2018

This is an MPFR assertion failure, so it looks like a bug in MPFR that should be reported there?

@simonbyrne
Copy link
Member

The MPFR release notes state that they fixed a bug related to erfc:

The mpfr_erf and mpfr_erfc functions can yield an assertion failure due to the fact that the error bound is computed with the double type and can overflow. This bug is fixed by the erf patch, which also provides testcases.
Corresponding changeset in the 4.0 branch: 12950.

But Julia 1.0.1 is using MPFR 4.0.1, so maybe this is different?

@stevengj
Copy link
Member

Nope, it seems like the problem is still present with Julia 1.0.1 and MPFR 4.0.1:

julia> using SpecialFunctions

julia> erfc(big"30.5")
/Users/osx/buildbot/slave/package_osx64/build/deps/srccache/mpfr-4.0.1/src/uceil_log2.c:40: MPFR assertion failed: exp < 1023

@simonbyrne
Copy link
Member

I don't quite understand their release notes, but it looks like those are the bugs that have been identified in the 4.0.1 release (since it seems like patch 11 is not in 4.0.1).

So looks like we need to wait until the next MPFR release.

@dlichtistw
Copy link
Author

Since switching to Julia 1.0.2 did not solve the problem for me either, I built my own libmpfr from subversion (revision 13311) and placed it in julia's lib directory. The result is positive.

julia> erfc(big"30")
2.564656203756111600033397277501447146548889722778617054122599586184238694779193e-393

So, this issue can probably be closed.

@ararslan
Copy link
Member

ararslan commented Dec 5, 2018

I think we should keep the issue open so we don't lose track of it, since we'll need to bump Julia's MPFR version when a newer one is available.

@simonbyrne
Copy link
Member

New version of MPFR has been released, see JuliaLang/julia#31041

@oscardssmith
Copy link
Member

Fixed on master.

@giordano
Copy link
Member

master of what? Julia?

@oscardssmith
Copy link
Member

I tested on a few day old master of Julia, with SpecialFunctions v1.4.2

@giordano
Copy link
Member

I can't reproduce with SpecialFunctions v0.7.1 on Julia v1.0.5 on linux, which is close to (but not exactly the same) the setup of the original report, so I'm not sure that the fact you can't reproduce the bug now with a recent version of Julia/SpecialFunctions means that the bug has been fixed, maybe you also couldn't reproduce it before. But it looks like no one else has been able to reproduce it either and the OP had already a working setup 2.5 years ago, so probably not worth keeping this open anyway.

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

No branches or pull requests

6 participants