Skip to contentSkip to conversation

stack: occasional crash due to uninitialized variable

PATCH Applied Andre Muezerie 2 participants 3 messages Feb 4, 2025 – Mar 6, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stack: occasional crash due to uninitialized variable

Variable "success" was not being initialized and there was a code path where the last do/while loop in __rte_stack_lf_pop_elems looked at the value of this variable before it was set to any.

Compiling with msvc resulted in stack_lf_autotest sometimes crashing.

The fix is to initialize the variable. This same fix was applied to stack\rte_stack_lf_generic.h in the past but was missed here.

Fixes 7e6e609939a8 ("stack: add C11 atomic implementation")
---
 lib/stack/rte_stack_lf_c11.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/stack/rte_stack_lf_c11.h +1 -1
index 60d46e963b..ee1c79c095 100644
@@ -77,7 +77,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list,
 {
 	struct rte_stack_lf_head old_head;
 	uint64_t len;
-	int success;
+	int success = 0;
 
 	/* Reserve num elements, if available */
 	len = rte_atomic_load_explicit(&list->len, rte_memory_order_relaxed);
Signature · 1 line
2.47.2.vfs.0.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andre Muezerie

Variable "success" was not being initialized and there was a code path where the last do/while loop in __rte_stack_lf_pop_elems looked at the value of this variable before it was set to any.

Compiling with msvc resulted in stack_lf_autotest sometimes crashing.

Quoted 7 lines

The fix is to initialize the variable. This same fix was applied to stack\rte_stack_lf_generic.h in the past but was missed here.

Fixes 7e6e609939a8 ("stack: add C11 atomic implementation")

Indeed, good catch.

Signature · 1 line
David Marchand
#2 lore raw
In reply to Andre Muezerie
Quoted 7 lines · Andre Muezerie

Variable "success" was not being initialized and there was a code path where the last do/while loop in __rte_stack_lf_pop_elems looked at the value of this variable before it was set to any.

Compiling with msvc resulted in stack_lf_autotest sometimes crashing.

Quoted 7 lines

The fix is to initialize the variable. This same fix was applied to stack\rte_stack_lf_generic.h in the past but was missed here.

Fixes 7e6e609939a8 ("stack: add C11 atomic implementation")

Applied, thanks.

Signature · 1 line
David Marchand