summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Hudson <rlh@golang.org>2014-10-23 15:51:17 -0400
committerRick Hudson <rlh@golang.org>2014-10-23 15:51:17 -0400
commit978c971bacf92ee97b8e24ce45b485afa1c31fad (patch)
treeeb027d60a93732edaf1aa1f4bb52c56304ed102b
parent78db2eb9c66d478bee0d56edcc55d4f865f8c6c7 (diff)
downloadgo-978c971bacf92ee97b8e24ce45b485afa1c31fad.tar.gz
[dev.garbage] runtime: simplifiy lfstack.c due to undiagnosed buffer corruption.
The changes got rid of the problems we were seeing. We suspect the pushcnt field has a race. LGTM=rsc R=dvyukov, rsc CC=golang-codereviews https://codereview.appspot.com/159330043 Committer: Russ Cox <rsc@golang.org>
-rw-r--r--src/runtime/lfstack.c14
-rw-r--r--src/runtime/runtime.h2
2 files changed, 7 insertions, 9 deletions
diff --git a/src/runtime/lfstack.c b/src/runtime/lfstack.c
index 57e0af282..0ced839c2 100644
--- a/src/runtime/lfstack.c
+++ b/src/runtime/lfstack.c
@@ -46,7 +46,7 @@ runtime·lfstackpush(uint64 *head, LFNode *node)
new = (uint64)(uintptr)node|(((uint64)node->pushcnt&CNT_MASK)<<PTR_BITS);
for(;;) {
old = runtime·atomicload64(head);
- node->next = (LFNode*)(uintptr)(old&PTR_MASK);
+ node->next = old;
if(runtime·cas64(head, old, new))
break;
}
@@ -55,19 +55,17 @@ runtime·lfstackpush(uint64 *head, LFNode *node)
LFNode*
runtime·lfstackpop(uint64 *head)
{
- LFNode *node, *node2;
- uint64 old, new;
+ LFNode *node;
+ uint64 old, next;
for(;;) {
old = runtime·atomicload64(head);
if(old == 0)
return nil;
node = (LFNode*)(uintptr)(old&PTR_MASK);
- node2 = runtime·atomicloadp(&node->next);
- new = 0;
- if(node2 != nil)
- new = (uint64)(uintptr)node2|(((uint64)node2->pushcnt&CNT_MASK)<<PTR_BITS);
- if(runtime·cas64(head, old, new))
+ next = runtime·atomicload64(&node->next);
+
+ if(runtime·cas64(head, old, next))
return node;
}
}
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index bea773799..37929c59c 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -573,7 +573,7 @@ enum {
// Lock-free stack node.
struct LFNode
{
- LFNode *next;
+ uint64 next;
uintptr pushcnt;
};