[odb-users] Coredump in multithreading environment and one
transaction
Javier Gutierrez
javier.gutierrez at web.de
Tue Apr 21 11:52:26 EDT 2020
Hi Boris,
I have a bunch of threads that share the same transaction. All of them run
different queries concurrently.
For running the query they call a function passing the transaction and the
odb::query by value.
The transaction is passed as an object that contains the odb::transaction
and a std::mutex.
So this function locks the mutex, sets the transaction as odb::current, runs
the query and returns the result to the calling thread.
Then the thread reads the result in a for-loop.
The segmentation fault occurs (if it occurs) when returning the result.
Of course when the function returns, the locking of the mutex goes out of
scope. Now if I make a test and run the for-loop of the result inside the
scope of the mutex then I get no coredump (at least this is the conclusion I
got to).
But my understanding is that reading the result of the locked area should
not be a problem since the result is cached (i.e. the odb::query run with
the cache flag = true).
Any idea why I might be getting the segmentation fault here? Hope the
explanation is clear...
Regards,
Javier Gutierrez
More information about the odb-users
mailing list