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
coro: protect first initialization of coroutine with new API (#3055)
When libco starts, it might enter in a race condition if multiple
threads are trying to initialize the 'co_swap' function, this check
is done on every coroutine creation:
==346246== Possible data race during read of size 8 at 0x5CA890 by thread #5
==346246== Locks held: none
==346246== at 0x48EFAE: co_create (amd64.c:132)
==346246== by 0x173035: flb_output_coro_create (flb_output.h:511)
==346246== by 0x173035: output_thread (flb_output_thread.c:281)
==346246== by 0x1889BE: step_callback (flb_worker.c:44)
==346246== by 0x4843B1A: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_helgrind-amd64-linux.so)
==346246== by 0x487E58F: start_thread (pthread_create.c:463)
==346246== by 0x4F47222: clone (clone.S:95)
==346246==
==346246== This conflicts with a previous write of size 8 by thread #4
==346246== Locks held: none
==346246== at 0x48EFCB: co_create (amd64.c:134)
==346246== by 0x173035: flb_output_coro_create (flb_output.h:511)
==346246== by 0x173035: output_thread (flb_output_thread.c:281)
==346246== by 0x1889BE: step_callback (flb_worker.c:44)
==346246== by 0x4843B1A: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_helgrind-amd64-linux.so)
==346246== by 0x487E58F: start_thread (pthread_create.c:463)
==346246== by 0x4F47222: clone (clone.S:95)
==346246== Address 0x5ca890 is 0 bytes inside data symbol "co_swap"
This patch introduce a new API for flb_coro interface that aims to
be called inside every worker thread. The access to this first
initialization is protected.
No more race conditions on that piece of code has been seen with valgrind
after the usage of this new function (next patches).
Signed-off-by: Eduardo Silva <eduardo@treasure-data.com>
0 commit comments