-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Calling external library that catches exception internally causes crash of julia #10273
Comments
It looks like the CoolProp C API is not exception safe. Julia doesn't know anything about C++ exceptions, so you need to wrap your internal calls in a The CoolProp Cython wrapper explicitly annotates the fact that these functions may throw, so you get exception handling for free from Cython. |
The CoolProp::PropsSI function catches all exceptions and does not allow On Sat, Feb 21, 2015 at 6:26 PM, Isaiah [email protected] wrote:
|
BTW, I am one of the main developers of CoolProp, so I have a pretty good On Sat, Feb 21, 2015 at 6:51 PM, Ian Bell [email protected] wrote:
|
I built the library and can't reproduce this in either 0.4 or 0.3.6. note: built with |
|
How did you build the library? On Sat, Feb 21, 2015 at 8:09 PM, Isaiah [email protected] wrote:
|
|
Hmm, myself and another developer have used a similar procedure to cause On Sat, Feb 21, 2015 at 8:17 PM, Isaiah [email protected] wrote:
|
Out of curiosity, what compiler do you use? On Sat, Feb 21, 2015 at 8:22 PM, Ian Bell [email protected] wrote:
|
gcc |
I thought it may have been the -O3 that would make the difference, but I still have the crash without. The way I first compiled: git clone https://github.com/CoolProp/CoolProp --recursive
cd CoolProp
mkdir build && cd build
cmake .. -DCOOLPROP_64BIT_SHARED_LIBRARY=ON
cmake --build . The way I tested seeing @ihnorton's commands: git clone https://github.com/CoolProp/CoolProp --recursive
cd CoolProp
mkdir build && cd build
ccmake ../../CoolProp -DCOOLPROP_64BIT_SHARED_LIBRARY=ON # c c g # I'm not used to ccmake, so this may not be the good way
make Then: sudo cp ./CoolProp/build/libCoolProp.so /usr/lib/x86_64-linux-gnu/julia/CoolProp.so And the wrapper (from the github) is placed in /home/johndoe/.julia/v0.3/CoolProp/src/CoolProp.jl And I keep having the crash instead of an |
Yes, exactly the same build steps ( |
I tested on a fresh virtual machine with Ubuntu gnome 14.10 64bit up to date, French system language. All the command below where send on a same terminal one after the other, starting in the home directory and continue in the ./CoolProp folder after entering it. It thus should be fully reproducible. I started to install Julia: sudo add-apt-repository ppa:staticfloat/julianightlies
sudo add-apt-repository ppa:staticfloat/julia-deps
sudo apt install julia Than the tool for sudo apt install cmake-curses-gui Than download and build CoolProp: git clone https://github.com/CoolProp/CoolProp --recursive
cd CoolProp
ccmake ../CoolProp -DCOOLPROP_64BIT_SHARED_LIBRARY=ON # c c g
make Than I ran Julia: user@vm-user:~/CoolProp$ julia _
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.0-dev+3472 (2015-02-20 05:10 UTC)
_/ |\__'_|_|_|\__'_| | Commit 8c87a32* (2 days old master)
|__/ | x86_64-linux-gnu julia> push!(DL_LOAD_PATH,".")
1-element Array{Union(ASCIIString,UTF8String),1}:
"."
julia> module CoolProp
export PropsSI
function PropsSI(Output::String, Name1::String, Value1::Float64, Name2::String, Value2::Float64, Fluid::String)
return ccall( (:PropsSI, "libCoolProp"), Cdouble, (Ptr{Uint8},Ptr{Uint8},Cdouble,Ptr{Uint8},Cdouble,Ptr{Uint8}), Output,Name1,Value1,Name2,Value2,Fluid)
end
end #module
julia> import CoolProp
julia> CoolProp.PropsSI("T","P",101325.0,"Q",0.0,"Water")
373.12429584768836
julia> CoolProp.PropsSI("T","P",-101325.0,"Q",0.0,"Water")
signal (6): Abandon
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_Unwind_Resume at /lib/x86_64-linux-gnu/libgcc_s.so.1 (unknown line)
_ZN8CoolProp16_PropsSI_outputsERNSt3tr110shared_ptrINS_13AbstractStateEEESt6vectorINS_16output_parameterESaIS6_EENS_11input_pairsERKS5_IdSaIdEESD_RS5_ISB_SaISB_EE at ./libCoolProp.so (unknown line)
_ZN8CoolProp13_PropsSImultiERKSt6vectorISsSaISsEERKSsRKS0_IdSaIdEES6_SA_S6_S4_SA_RS0_IS8_SaIS8_EE at ./libCoolProp.so (unknown line)
_ZN8CoolProp7PropsSIERKSsS1_dS1_dS1_ at ./libCoolProp.so (unknown line)
PropsSI at ./libCoolProp.so (unknown line)
PropsSI at none:6
Abandon (core dumped) user@vm-user:~/CoolProp$ Apart from the system language and the graphical interface that could be different, I do not see anything different from what you done in the steps I wrote above. Have any idea of where the problem hides? |
I was using the generic linux download. I can reproduce this with the binary from the ppa. Will investigate. |
The issue with the PPA Julia looks similar to jump-dev/Ipopt.jl#9 - something about the version of libunwind in the PPA isn't working quite right. |
bump. |
How recent is your ppa build? See jump-dev/Ipopt.jl#9 (comment) which should have addressed this at least for the ppa build of Julia? |
@JonWel, can you try it out?
|
Release: Nightly: So the problem is corrected for the development version, but not yet for the release. |
This is now fixed for me for both ppa since: None of them crash any more. |
Great. (thanks @staticfloat!) |
@staticfloat Could this problem have happened again? I ran a code working correctly on signal (6): Abandon
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_Unwind_Resume at /lib/x86_64-linux-gnu/libgcc_s.so.1 (unknown line)
_ZN8CoolProp17SaturationSolvers23successive_substitutionERNS_26HelmholtzEOSMixtureBackendEdddRKSt6vectorIdSaIdEERS5_RNS0_14mixture_VLE_IOE at /usr/bin/../lib/x86_64-linux-gnu/julia/CoolProp.so (unknown line)
_ZN8CoolProp13FlashRoutines8PQ_flashERNS_26HelmholtzEOSMixtureBackendE at /usr/bin/../lib/x86_64-linux-gnu/julia/CoolProp.so (unknown line)
_ZN8CoolProp26HelmholtzEOSMixtureBackend6updateENS_11input_pairsEdd at /usr/bin/../lib/x86_64-linux-gnu/julia/CoolProp.so (unknown line)
_ZN8CoolProp20AbstractCubicBackend10saturationENS_11input_pairsE at /usr/bin/../lib/x86_64-linux-gnu/julia/CoolProp.so (unknown line)
_ZN8CoolProp20AbstractCubicBackend6updateENS_11input_pairsEdd at /usr/bin/../lib/x86_64-linux-gnu/julia/CoolProp.so (unknown line)
AbstractState_update at /usr/bin/../lib/x86_64-linux-gnu/julia/CoolProp.so (unknown line)
AbstractState_update at /home/johndoe/.julia/v0.4/CoolProp/src/CoolProp.jl:199
Julia has stopped: null, SIGABRT Which is extremely similar to the message we had here. Running julia:
Installed: 0.4.5-3
Candidate: 0.4.5-3
Version table:
*** 0.4.5-3 500
500 http://be.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
100 /var/lib/dpkg/status So the package is installed from the Ubuntu repository (I don't know how the communication with your own repository is done, and maybe installing from |
Are you using the PPA still? Try the generic linux binaries. |
@tkelman I've just updated my comment to add more information about that. I'm not using staticfloat's ppa but the version in Ubuntu repositories. There are in deed good chances the generic binaries doesn't have this problem. |
If that ends up being the case, then report this as a bug in the debian packaging. They're probably linking libunwind as a shared library, or using a version of libunwind that doesn't have patches we need. |
The crash do not occur with staticfloat's ppa. When doing the The following packages were automatically installed and are no longer required:
julia-common libdsfmt-19937-1 libopenlibm2 libopenspecfun1 libpcre2-8-0
libspqr2.0.2 libutf8proc1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libamd2.2.0 libcholmod1.7.1 libcolamd2.7.1 libfftw3-3 libfftw3-long3
librmath-julia-base librmath-julia-dev libumfpack5.4.0
Suggested packages:
ess julia-doc libfftw3-bin libfftw3-dev
The following NEW packages will be installed:
libamd2.2.0 libcholmod1.7.1 libcolamd2.7.1 libfftw3-3 libfftw3-long3
librmath-julia-base librmath-julia-dev libumfpack5.4.0
The following packages will be upgraded:
julia (and How do I report that correctly to Ubuntu's package managers? |
Launchpad for Ubuntu I think, unless you can verify it also happens in debian. Might be a problem with both. |
I have a C++ library (CoolProp) that can be called using a shared library. When I call the function with inputs that cause an exception to be caught and bubbled in the library, it crashes julia, while the same set of inputs work fine in python and return HUGE as the output value.
Julia module:
and in julia
whereas in python, calling the same shared library, yields the infinite output values and no crash:
yields
The text was updated successfully, but these errors were encountered: