giordano / Cuba.jl

Library for multidimensional numerical integration with four independent algorithms: Vegas, Suave, Divonne, and Cuhre.
https://giordano.github.io/Cuba.jl/stable
MIT License
75 stars 9 forks source link

Crash at maxevals=100 #12

Open improbable-22 opened 7 years ago

improbable-22 commented 7 years ago

This gives a segmentation fault error:

using Cuba 
vegas((x, f) -> f[1] = cos(x[1]), maxevals=100)

It works fine at 1000, and also this works fine:

vegas((x, f) -> f[1] = cos(x[1]), nstart=99, nincrease=99, maxevals=100)

I get a similar error from other functions (suave, divonne, cuhre) at maxevals=100.

Cuba 0.4.0, Julia 0.6.0, on a mac.

giordano commented 7 years ago

Sorry, I can't reproduce :-/

julia> vegas((x, f) -> f[1] = cos(x[1]), maxevals=100)
Component:
 1: 0.8422538728757027 ± 0.004375690491875356 (prob.: -999.0)
Integrand evaluations: 1000
Fail:                  1
Number of subregions:  0

Can you please post the full crash log?

giordano commented 7 years ago

One thing that you can try is to pin an old version (like v0.3.1) and see if vegas still crashes. In Julia run the command

Pkg.pin("Cuba", v"0.3.1")

then restart Julia and repeat

using Cuba 
vegas((x, f) -> f[1] = cos(x[1]), maxevals=100)

Anyway, a full crash log would still be very useful.

improbable-22 commented 7 years ago

OK thanks for taking a look! I've pasted in the whole log below. Will try the old version suggestion now.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0 (2017-06-19 13:05 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-apple-darwin13.4.0

julia> using Cuba

julia> vegas((x, f) -> f[1] = cos(x[1]), maxevals=100)

signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
Integrate at /Users/me/.julia/v0.6/Cuba/deps/libcuba.dylib (unknown line)
llVegas at /Users/me/.julia/v0.6/Cuba/deps/libcuba.dylib (unknown line)
dointegrate at /Users/me/.julia/v0.6/Cuba/src/Cuba.jl:172 [inlined]
#vegas#4 at /Users/me/.julia/v0.6/Cuba/src/vegas.jl:105
unknown function (ip: 0x1237ebbaa)
#vegas at ./<missing>:0
#vegas at ./<missing>:0
unknown function (ip: 0x1237ea252)
do_call at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:75
eval at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:242
eval_body at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:539
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:692
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:592
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/builtins.c:496
eval at ./boot.jl:235
jlcall_eval_17976 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
eval_user_input at ./REPL.jl:66
jlcall_eval_user_input_20272 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x1237e392f)
jl_apply at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia.h:1424 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/task.c:267
Allocations: 1025872 (Pool: 1024743; Big: 1129); GC: 0

[Process completed]
improbable-22 commented 7 years ago

Using v0.3.1 as suggested, it now runs fine:

julia> Pkg.pin("Cuba", v"0.3.1")
INFO: Creating Cuba branch pinned.fcbd97ff.tmp
INFO: No packages to install, update or remove

julia> using Cuba
INFO: Recompiling stale cache file /Users/me/.julia/lib/v0.6/Cuba.ji for module Cuba.

julia> vegas((x, f) -> f[1] = cos(x[1]), maxevals=100)
([0.842254], [0.00437569], [-999.0], 1000, 1, 0)

julia> suave((x, f) -> f[1] = cos(x[1]), maxevals=100)
([0.842254], [0.00437569], [-999.0], 1000, 1, 1)
giordano commented 7 years ago

This is a weird issue. I tested maxevals=100 on AppVeyor and Travis and with both versions 0.3.1 and 0.4.0 of Cuba.jl:

As you can see, there are failures also with the previous version of the package. I'm running Julia 0.7 on GNU/Linux, which seems to be one of the few configurations that never fail.

Honestly, I can't understand what's wrong with maxevals=100. I'll try to track the culprit, but can't do any promise.

improbable-22 commented 7 years ago

OK thanks for having a look. For now I can work around it of course.

giordano commented 7 years ago

I asked for help on Discourse: it turned out this may actually be a bug in Cuba library. In particular, at line 24 of src/common/Random.c uninitialized memory is read.

Could you please report the issue to Thomas Hahn (Cuba's author)? You can find his contact at http://wwwth.mpp.mpg.de/members/hahn/ Maybe point him to the Discourse thread, were more information about the bug are provided.

improbable-22 commented 7 years ago

OK I sent him an email, with these links.

giordano commented 6 years ago

Out of curiosity, did you get any reply?

improbable-22 commented 6 years ago

Hi giordano, no I did not hear anything.

giordano commented 6 years ago

I also tried to get in contact with him in the past, to no avail. So that's not only me. Thank you.