[Webkit-unassigned] [Bug 142513] New: 8-bit version of weakCompareAndSwap() can cause an infinite loop
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Mar 9 16:18:04 PDT 2015
https://bugs.webkit.org/show_bug.cgi?id=142513
Bug ID: 142513
Summary: 8-bit version of weakCompareAndSwap() can cause an
infinite loop
Classification: Unclassified
Product: WebKit
Version: 528+ (Nightly build)
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: Web Template Framework
Assignee: webkit-unassigned at lists.webkit.org
Reporter: mark.lam at apple.com
Presently, Bitmap::concurrentTestAndSet() uses the 8-bit version of weakCompareAndSwap() (which compares and swaps an uint8_t value). Bitmap::concurrentTestAndSet() has a loop that checks if a bit in the byte of interest has been set. If not, it will call the 8-bit CAS function to set the bit.
Under the covers, the 8-bit CAS function actually works with a 32-bit CAS. The 8-bit CAS will first fetch the 32-bit value in memory that contains the 8-bit value, and check if it contains the expected byte. If the value in memory doesn't have the expected byte, it will return early to its caller. The expectation is that the caller will reload the byte from memory and call the 8-bit CAS again.
Unfortunately, this code path that returns early does not have a compiler fence. Without that compiler fence, the C++ compiler can optimize away the reloading of the expected byte value, leaving it unchanged. As a result, we'll have a infinite loop here that checks a value that will never change, and the loop will not terminate until the value changes.
The fix is to eliminate the early return check in the 8-bit CAS, and have it always call down to the 32-bit CAS. The 32-bit CAS has a compiler fence which will prevent this issue.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150309/87b04843/attachment-0002.html>
More information about the webkit-unassigned
mailing list