-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
I work with embedded julia (I don't use julia interpreter, I use libjulia-* libraries directly) and due to certain problems (forced termination of the adopted thread (it makes with help of jl_adopt_thread() API, which executes julia code)
Line 436 in 7de5585
| JL_DLLEXPORT jl_gcframe_t **jl_adopt_thread(void) |
It became necessary to reinitialize the code generation subsystem (calling jl_teardown_codegen() and jl_init_codegen()), since julia remained in an incorrect state when the thread was terminated (locks in the code generation subsystem were not released). However, the reinitialization fails due to the "Library already loaded" error in the sys::DynamicLibrary::addPermanentLibrary (
Lines 1945 to 1948 in 7de5585
| sys::DynamicLibrary libjulia_internal_dylib = sys::DynamicLibrary::addPermanentLibrary( | |
| jl_libjulia_internal_handle, &ErrorStr); | |
| if(!ErrorStr.empty()) | |
| report_fatal_error(llvm::Twine("FATAL: unable to dlopen libjulia-internal\n") + ErrorStr); |
libjulia-internal (obviously, because it has already been loaded before) and as a result, abortion is called. Ignoring this error completely solves this problem. The documentation for the addPermanentLibrary function says that it can be safely called many times for the same library.
My suggestion is to ignore this error on initialization step:
sys::DynamicLibrary libjulia_internal_dylib = sys::DynamicLibrary::addPermanentLibrary(
jl_libjulia_internal_handle, &ErrorStr);
if(!ErrorStr.empty())
if (ErrorStr != "Library already loaded")
report_fatal_error(llvm::Twine("FATAL: unable to dlopen libjulia-internal\n") + ErrorStr);