-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hi @Clemapfel,
I am trying to use Jluna to support tasks written in Julia into a streaming library I'm working on (StreamPU).
I have the following minimal code:
#include <jluna.hpp>
int main(int argc, char** argv)
{
jluna::initialize(3);
const size_t n_tasks = 12;
std::vector<jluna::Task<void>> tasks;
std::function<void(const size_t)> func_exec = [](const size_t tid)
{
jluna::Base["println"]("lambda called with ", tid);
};
for (size_t tid = 0; tid < n_tasks; tid++)
{
tasks.push_back(jluna::ThreadPool::create(func_exec, tid));
tasks.back().schedule();
}
for (size_t tid = 0; tid < n_tasks; tid++)
tasks[tid].join();
return 0;
}Most of the time this code will print something like:
[JULIA][LOG] initialization successful (3 thread(s)).
lambda called with 5
lambda called with 6
lambda called with 8
lambda called with 0
lambda called with 7
lambda called with 1
lambda called with 2
lambda called with 10
lambda called with 9
lambda called with 4
lambda called with 3
lambda called with 11
But sometimes it failes with the following error:
[JULIA][LOG] initialization successful (3 thread(s)).
^[[Aterminate called after throwing an instance of 'jluna::JuliaException'
what(): [JULIA][EXCEPTION] KeyError: key 0x0000773229fd79a0 not found
Stacktrace:
[1] getindex
@ ./dict.jl:498 [inlined]
[2] get_reference(key::UInt64)
@ Main.jluna.memory_handler ./none:597
[3] safe_call(f::Function, args::UInt64)
@ Main.jluna ./none:17
[4] (::Main.jluna.cppcall.var"#3#4"{UInt64})()
@ Main.jluna.cppcall ./none:828
[217830] signal (6.-6): Aborted
in expression starting at none:0
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x77323dca5ffd)
unknown function (ip: 0x77323dcbae9b)
_ZSt9terminatev at /lib/x86_64-linux-gnu/libstdc++.so.6 (unknown line)
__cxa_throw at /lib/x86_64-linux-gnu/libstdc++.so.6 (unknown line)
safe_call<_jl_value_t*> at /nfs/users/cassagnea-nfs/softwares/jluna/include/jluna/.src/safe_utilities.inl:56
_ZN5jluna6detail13get_referenceEm at /nfs/users/cassagnea-nfs/softwares/jluna/lib/libjluna.so.1.0.0 (unknown line)
_ZN5jluna5Proxy10ProxyValueC2EP11_jl_value_tRSt10shared_ptrIS1_ES3_ at /nfs/users/cassagnea-nfs/softwares/jluna/lib/libjluna.so.1.0.0 (unknown line)
_ZN5jluna5ProxyC2EP11_jl_value_tRSt10shared_ptrINS0_10ProxyValueEES2_ at /nfs/users/cassagnea-nfs/softwares/jluna/lib/libjluna.so.1.0.0 (unknown line)
operator[]<char> at /nfs/users/cassagnea-nfs/softwares/jluna/include/jluna/.src/proxy.inl:78 [inlined]
operator() at /nfs/users/cassagnea-nfs/workspace/devel/streampu_julia/tests/julia/simple_chain_julia.cpp:75 [inlined]
__invoke_impl<void, main(int, char**)::<lambda(size_t)>&, long unsigned int> at /usr/include/c++/13/bits/invoke.h:61 [inlined]
__invoke_r<void, main(int, char**)::<lambda(size_t)>&, long unsigned int> at /usr/include/c++/13/bits/invoke.h:111 [inlined]
_M_invoke at /usr/include/c++/13/bits/std_function.h:290
operator() at /usr/include/c++/13/bits/std_function.h:591 [inlined]
operator() at /nfs/users/cassagnea-nfs/softwares/jluna/include/jluna/.src/multi_threading.inl:345 [inlined]
__invoke_impl<_jl_value_t*, jluna::ThreadPool::create<long unsigned int>(const std::function<void(long unsigned int)>&, long unsigned int)::<lambda()>&> at /usr/include/c++/13/bits/invoke.h:61 [inlined]
__invoke_r<_jl_value_t*, jluna::ThreadPool::create<long unsigned int>(const std::function<void(long unsigned int)>&, long unsigned int)::<lambda()>&> at /usr/include/c++/13/bits/invoke.h:114 [inlined]
_M_invoke at /usr/include/c++/13/bits/std_function.h:290
_ZNKSt8functionIFP11_jl_value_tvEEclEv at /nfs/users/cassagnea-nfs/softwares/jluna/libjluna.so (unknown line)
jluna_invoke_from_task at /nfs/users/cassagnea-nfs/softwares/jluna/libjluna.so (unknown line)
#3 at ./none:828
unknown function (ip: 0x77323d468737)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
start_task at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/task.c:1238
Allocations: 2908 (Pool: 2899; Big: 9); GC: 0
Aborted (core dumped)
I am using a Zen 4 CPU with 8 cores on Ubuntu 24.04. I compiled Jluna from this repository (7b08c4f) and my Julia version is 1.10.4.
Do you have any ideas why this error happens? Should I make things differently? It worth mentioning that I'm not very experienced in Julia programming.
Many thanks in advance for any help.
Metadata
Metadata
Assignees
Labels
No labels