From 4e177047c99cdea83a2b0349e7e04c7fd97c7d32 Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Thu, 30 Apr 2026 03:55:15 +0000 Subject: [PATCH] fix: correct SEL_NUM bit-cast in gc test; assert n1 swept; add recompact to protocol comment --- src/include/resreq.h | 2 +- src/lib/testsuite/test_select.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/include/resreq.h b/src/include/resreq.h index b0c7ae9e..380e53ea 100644 --- a/src/include/resreq.h +++ b/src/include/resreq.h @@ -123,7 +123,7 @@ extern void recompact_node_ids(void); /* GC mark primitives — called by scheduler to implement the mark phase. * Protocol: gc_clear_marks() → gc_mark_select_tree(root) per live node - * → gc_sweep_select_nodes(NULL, 0) */ + * → gc_sweep_select_nodes(NULL, 0) → recompact_node_ids() */ extern void gc_clear_marks(void); extern void gc_mark_select_tree(xce_select_node_t* node); diff --git a/src/lib/testsuite/test_select.c b/src/lib/testsuite/test_select.c index 346fa664..736fc431 100644 --- a/src/lib/testsuite/test_select.c +++ b/src/lib/testsuite/test_select.c @@ -2193,8 +2193,12 @@ test_gc_clear_marks_exported(void) sel_optimize_set(1); sel_node_table_init(); - xce_select_node_t* n1 = makeSelectNode(SEL_NUM, (uintptr_t)1.0, 0); - xce_select_node_t* n2 = makeSelectNode(SEL_NUM, (uintptr_t)2.0, 0); + double d1 = 1.0, d2 = 2.0; + uintptr_t b1, b2; + memcpy(&b1, &d1, sizeof(b1)); + memcpy(&b2, &d2, sizeof(b2)); + xce_select_node_t* n1 = makeSelectNode(SEL_NUM, b1, 0); + xce_select_node_t* n2 = makeSelectNode(SEL_NUM, b2, 0); TEST_ASSERT_NOT_NULL(n1); TEST_ASSERT_NOT_NULL(n2); @@ -2213,6 +2217,11 @@ test_gc_clear_marks_exported(void) gc_sweep_select_nodes(NULL, 0); TEST_ASSERT_EQUAL_INT(1, n2->gc_mark); + /* verify n1 was swept — re-interning gives a fresh allocation */ + xce_select_node_t* n1_again = makeSelectNode(SEL_NUM, b1, 0); + TEST_ASSERT_NOT_NULL(n1_again); + TEST_ASSERT_NOT_EQUAL(n1, n1_again); /* different pointer = n1 was freed */ + sel_node_table_fini(); sel_optimize_test_reset(); }