This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 4/5] Fix deadlock in _int_free consistency check
- From: DJ Delorie <dj at redhat dot com>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: libc-alpha at sourceware dot org, nd at arm dot com
- Date: Thu, 12 Oct 2017 16:49:44 -0400
- Subject: Re: [PATCH 4/5] Fix deadlock in _int_free consistency check
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dj at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 71D42C059B81
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.