[llvm-bugs] [Bug 25500] New: Atomic compare_exchange_weak/strong
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 11 21:10:16 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25500
Bug ID: 25500
Summary: Atomic compare_exchange_weak/strong
Product: libc++
Version: 3.7
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: venkat.murty at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
Classification: Unclassified
Created attachment 15269
--> https://llvm.org/bugs/attachment.cgi?id=15269&action=edit
A test c++ code that shows the bug. It spawns 8 threads.
The following snippet does not work as expected.
struct Node { Node* next; };
std::atomic<Node*> head (nullptr);
// Is like free
void push (void* p)
{
Node* n = (Node*) p;
n->next = head.load ();
while (!head.compare_exchange_strong (n->next, n));
}
// is like malloc
void* pop ()
{
Node* n = head.load ();
while (n &&
!head.compare_exchange_strong (n, n->next));
return n ? n : malloc (SIZE);
}
The attached file with the driver crashes every 1 in 5 times.
clang++ -g -std=c++11 test.cpp
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151112/6424694c/attachment.html>
More information about the llvm-bugs
mailing list