From 52ed5a9bf84ecf48def088c13e95af95bb5d24a5 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Tue, 9 Dec 2014 21:48:14 -0700 Subject: [PATCH] opal_lifo: fix one more potential issue with the new 128-bit lifo atomics It is possible the compiler can reorder the read of the head item and the head itself. This could lead to a situation where the item returned was not really the head item. --- opal/class/opal_lifo.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opal/class/opal_lifo.h b/opal/class/opal_lifo.h index fa7218c8c5..9d6e07d9c7 100644 --- a/opal/class/opal_lifo.h +++ b/opal/class/opal_lifo.h @@ -139,8 +139,10 @@ static inline opal_list_item_t *opal_lifo_pop_atomic (opal_lifo_t* lifo) do { opal_counted_pointer_t old_head; + opal_atomic_rmb (); + old_head.value = lifo->opal_lifo_head.value; - item = (opal_list_item_t *) lifo->opal_lifo_head.data.item; + item = old_head.data.item; if (item == &lifo->opal_lifo_ghost) { return NULL;