You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our Java SWIG wrappers can lead to an irrecoverable crash of the main process when allocating arrays in SWIG. This was reported in SWIG but unfortunately there was no feedback: swig/swig#1755.
Since this PR (#2859) copies that code quasi-verbatim, from carrays.i, I'll wait for it to be approved to submit changes.
There are 2 ways to fix this:
Easier) Use operator new (nothrow) -> return null pointer if memory allocation fails
Harder) Use more SWIG code to wrap the std::bad_alloc exception. -> throw OutOfMemory exception
The text was updated successfully, but these errors were encountered:
AlbertoEAF
changed the title
[SWIG] Catch std::bad_alloc with carrays.i wrappers
[SWIG] Prevent irrecoverable crash when allocating arrays
Mar 25, 2020
Hello Guolinke,
It could be fixed by wrapping with an exception in C++ & SWIG or returning
a void pointer which can be wrapped to return an OutOfMemory exception in
Java.
Although this can be fixed at any time as it does not change the API, this
is far from my priority list so maybe we can close it if you want?
Thank you
Our Java SWIG wrappers can lead to an irrecoverable crash of the main process when allocating arrays in SWIG. This was reported in SWIG but unfortunately there was no feedback: swig/swig#1755.
Since this PR (#2859) copies that code quasi-verbatim, from carrays.i, I'll wait for it to be approved to submit changes.
There are 2 ways to fix this:
Easier) Use operator
new (nothrow)
-> return null pointer if memory allocation failsHarder) Use more SWIG code to wrap the
std::bad_alloc
exception. -> throw OutOfMemory exceptionThe text was updated successfully, but these errors were encountered: