aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-02-05 06:42:26 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-02-05 06:42:26 -0800
commitcef91a5c4f6858bd2dd79a47091ba640e0ee00a0 (patch)
tree22d70e042c2b4ef651a9f93901464c256f6edb76
parentf6c7951e448745c61302216eb78147bdcd399488 (diff)
parent0c598b08ac06a5e2b1a4ed022bbb60e4e999624e (diff)
Merge pull request #5081 from vjpai/dbg_async
Write to dummy pads and invalid entries in lock-free stack to prevent valgrind complaints
-rw-r--r--src/core/support/stack_lockfree.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c
index cd0afddf9d..2c97ee18be 100644
--- a/src/core/support/stack_lockfree.c
+++ b/src/core/support/stack_lockfree.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -99,6 +99,11 @@ gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) {
/* Point the head at reserved dummy entry */
stack->head.contents.index = INVALID_ENTRY_INDEX;
+ /* Fill in the pad and aba_ctr to avoid confusing memcheck tools */
+#ifdef GPR_ARCH_64
+ stack->head.contents.pad = 0;
+#endif
+ stack->head.contents.aba_ctr = 0;
return stack;
}
@@ -115,6 +120,11 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
/* First fill in the entry's index and aba ctr for new head */
newhead.contents.index = (uint16_t)entry;
+#ifdef GPR_ARCH_64
+ /* Fill in the pad to avoid confusing memcheck tools */
+ newhead.contents.pad = 0;
+#endif
+
/* Also post-increment the aba_ctr */
curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm);
newhead.contents.aba_ctr = ++curent.contents.aba_ctr;