[PATCH 4/5] Fix deadlock in _int_free consistency check
DJ Delorie
dj@redhat.com
Thu Oct 12 20:49:00 GMT 2017
I think the bug can be fixed by only changing the sense of the have_lock
condition:
> - if (!have_lock
> + if (have_lock
The code around this patch looks like
if (error detected)
{
/* patch goes here */
print error message
}
What we *want* is
if (error detected)
{
if (didn't have lock)
get lock, redo test
print error message if still an error
}
so...
if (error detected)
{
if (have_lock)
/* we had the lock during the test above, so the test is valid,
and the error we detect is valid. */
print error message
else
/* we didn't have the lock, so aquire it and repeat the test. If
the error is still present, fail. */
get lock, repeat test, maybe print error message
}
which reduces to
if (error detected)
{
if (have_lock /* in which case, above test is usable as-is, it's an error */
OR (get lock, repeat test, still an error))
print error message
}
Which is what the current upstream code is, except for the sense of the
have_lock test.
More information about the Libc-alpha
mailing list