[LLVMbugs] [Bug 8441] New: Race condition in AttributesList

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Oct 22 12:51:38 PDT 2010


           Summary: Race condition in AttributesList
           Product: new-bugs
           Version: 2.8
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: g at brewster.org
                CC: llvmbugs at cs.uiuc.edu

This bug seems to be a race condition relating to the static AttributesList in
Attributes.cpp. Access to the AttributesList is locked, but my theory for what
was going on is that at line 125-126, when dropping a reference, we decrement
the count, then check to see if it's zero, then delete "this" (if the refcount
was zero). After we've checked that the count is zero, but before deleting
"this", "this" is still in the AttributesLists set. So in the mean time,
another thread comes along, finds "this" in AttributesList, and references it.
But the first thread has already determined that the count *was* 0, and then
comes back and deletes "this", even though it's now in use by the second

I've attached a patch which seems to fix this problem for me -- not intended as
a final solution, but it is useful for illustrating the problem.

I'll attach a program which reproduces the problem once I figure out how to
have multiple attachements.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list