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

lib, tests: fix some b0rked tests, then fix TSAN warnings #16258

Merged
merged 5 commits into from
Jul 9, 2024

Conversation

eqvinox
Copy link
Contributor

@eqvinox eqvinox commented Jun 20, 2024

First go around and fix a bunch of mixups in test_seqlock, then make TSAN understand that the world is not on fire.

Fixes: #16244 (hopefully)

eqvinox added 4 commits June 20, 2024 11:02
seqlock_bump() used to return the value before bumping, but that's
unhelpful if you were to actually need it.  I had changed it to return
the value after, but the update to the test got lost at some point.

The return value is not in fact used anywhere in FRR, so while it is
a bug, it has zero impact.

NB: yes, test_seqlock is not run, which sounds wrong.  The problem here
is that (a) the test itself uses sleeps and is timing sensitive, which
would raise false positives.  And (b), the test is meaningless if
executed once.  It needs to be run millions of times under various
conditions (e.g. load) to catch rare races, and it needs to be run on
machines with "odd" memory models (in this case I used BE ppc32 and
ppc64 systems as test platforms.)

Fixes: 6046b69 ("lib/seqlock: avoid syscalls in no-waiter cases")
Signed-off-by: David Lamparter <[email protected]>
I lost an underscore somewhere along the way.  Which never caused issues
because we don't use that function macro.  It is, however, useful for
testing, so fix it.

Signed-off-by: David Lamparter <[email protected]>
TSAN warns about leaving the second thread dangling.  Doesn't really
matter, but just add a pthread_join to get rid of the warning.

Signed-off-by: David Lamparter <[email protected]>
TSAN doesn't understand the OS specific "fast" seqlock code.  Use the
pthread mutex/condvar based path when TSAN is enabled.

Signed-off-by: David Lamparter <[email protected]>
The atomlist test consists of a sequence of (MT) sub-tests, from which
counters are collected and verified.  TSAN doesn't know that these
counters are synchronized by way of the sub-test starting and finishing,
so it complains.  Just use atomics to get rid of the warning.

(This is solely an issue with the test, not the atomlist code.  There
are no warnings from that.)

Signed-off-by: David Lamparter <[email protected]>
@donaldsharp donaldsharp self-requested a review July 2, 2024 15:54
Copy link
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@riw777 riw777 merged commit 22db85a into FRRouting:master Jul 9, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thread Sanitizer data race in rcu code
2 participants