Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in master branch #2908

Closed
hsmatulisgoogle opened this issue Jan 6, 2021 · 2 comments
Closed

Race condition in master branch #2908

hsmatulisgoogle opened this issue Jan 6, 2021 · 2 comments
Assignees

Comments

@hsmatulisgoogle
Copy link
Contributor

Here is a race condition I found when debugging on master:

ch_parent_events is created in the worker thread without any signalling, so the parent can attempt to use it before its been defined:

/*
* Event loop setup between parent engine and this thread
*
* - FLB engine uses 'ch_parent_events[1]' to dispatch tasks to this thread
* - Thread receive message on ch_parent_events[0]
*
* The mk_event_channel_create() will attach the pipe read end ch_parent_events[0]
* to the local event loop 'evl'.
*/
ret = mk_event_channel_create(evl,
&th_ins->ch_parent_events[0],
&th_ins->ch_parent_events[1],
th_ins);

n = write(th_ins->ch_parent_events[1], &task, sizeof(struct flb_task *));

I imagine ch_thread_events would have a similar issue
/* Channel used by flush callbacks to notify it return status */
ret = mk_event_channel_create(evl,
&th_ins->ch_thread_events[0],
&th_ins->ch_thread_events[1],
&event_local);

@edsiper
Copy link
Member

edsiper commented Jan 7, 2021

ah! good one. So the pipe must be created in the output_thread interface before the thread is created, so it's just shared..

edsiper added a commit that referenced this issue Jan 8, 2021
@edsiper
Copy link
Member

edsiper commented Jan 8, 2021

Fixed in 78b0f6d

@edsiper edsiper self-assigned this Jan 8, 2021
@edsiper edsiper closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants