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 Conditions in qutil #238

Open
insertinterestingnamehere opened this issue Feb 12, 2024 · 1 comment
Open

Race Conditions in qutil #238

insertinterestingnamehere opened this issue Feb 12, 2024 · 1 comment
Labels
bug medium priority tsan Thread Sanitizer Errors

Comments

@insertinterestingnamehere
Copy link
Collaborator

I'm seeing a handful of thread sanitizer errors about race conditions in the qutil code.

One example: apparently the macro invoked at

INNER_LOOP(qutil_uint_mult_inner, qutil_uis_args, MULT_MACRO)
,
INNER_LOOP(qutil_uint_max_inner, qutil_uis_args, MAX_MACRO)
, and
INNER_LOOP(qutil_uint_min_inner, qutil_uis_args, MIN_MACRO)
includes both a read and a corresponding atomic write from another thread.

Another example:
non-atomic read:

aligned_t cur = *args->furthest_leftwall;

atomic write to the same variable:
tmp = qthread_cas(args->furthest_leftwall, cur, mine);

Similar:

aligned_t cur = *args->furthest_rightwall;

tmp = qthread_cas(args->furthest_rightwall, cur, mine);

Another more unusual one:
The macro invoked at

INNER_LOOP(qutil_int_mult_inner, qutil_is_args, MULT_MACRO)
has a non-atomic write as well as an atomic write to the same variable from a different thread via qthread_syncvar_fill at
UNLOCK_THIS_MODIFIED_SYNCVAR(addr, ret, 0);
.

@insertinterestingnamehere
Copy link
Collaborator Author

Poking at some of the memory fences for syncvars seems like a partial fix. Some additional atomics in the nemesis scheduler may be necessary to get the sequencing right, but at this point I'm still not sure. The weird thing though is that some of the thread sanitizer tracebacks here seem to be getting garbled and it's not at all clear why/how that's happening. It may be that a better-debugged #249 is needed to fix these warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug medium priority tsan Thread Sanitizer Errors
Projects
None yet
Development

No branches or pull requests

1 participant