-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Bug Report
There seems to be a race condition in libco:
fluent-bit/lib/flb_libco/amd64.c
Lines 132 to 135 in 5647069
if(!co_swap) { | |
co_init(); | |
co_swap = (void (*)(cothread_t, cothread_t))co_swap_function; | |
} |
Here
co_swap
is a static function pointer, which is assigned to a bunch of data in co_swap_function
that corresponds to assembly instructions before first use.
However this code assume that pointer assignment is regular, which is likely platform dependent. Better to use pthread_once
rather than checking if its null
.
This code should probably be using inline assembly macros instead of writing data to an unsigned char
and interpreting it as a function, then they wouldn't have to worry about initializing things before first use in the first place.