This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 4/5] Fix deadlock in _int_free consistency check


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]