Skip to content

Commit 82c4067

Browse files
DeusDatadarkverbito
andcommitted
fix(test): release the node retrieved per USAGE edge in the Chialisp contract
The cross-file Constant resolution test walks USAGE edges and calls cbm_store_find_node_by_id() for each source, which populates the caller's cbm_node_t with heap_strdup'd fields (store.c:195 via scan_node). It freed the arrays it owned -- consts and edges -- but never released the per-edge node, leaking one set of fields per iteration. LeakSanitizer caught it in every sanitizer-enabled lane while the plain test shards and both Windows legs stayed green, which is why the local test-runner could not see it: test-lsan-macos 417 bytes in 6 allocations test-unix (ubuntu-latest, 2/3) 401 bytes in 6 allocations test-unix (ubuntu-24.04-arm, 2/3) same signature test-diag same signature Use cbm_node_free_fields(), not cbm_store_free_nodes(). The latter frees the array pointer itself after releasing each element's fields, so calling it on a stack-allocated node is a bad free -- ASan aborts with "bad-free test_lang_contract.c" if you try. cbm_node_free_fields() releases the strdup'd members and leaves the struct alone, which is the idiom the neighbouring probes already use (test_edge_types_probe.c:245). The three other find_node_by_id call sites in this file predate this branch and already handle their own cleanup; only the new Chialisp contract leaked. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com> Co-authored-by: darkverbito <8049985+darkverbito@users.noreply.github.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent ee0a2e6 commit 82c4067

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎tests/test_lang_contract.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ TEST(contract_chialisp_constant_resolves_across_files) {
737737
if (src.file_path && strstr(src.file_path, "puzzle.clsp")) {
738738
cross_file++;
739739
}
740+
cbm_node_free_fields(&src);
740741
}
741742
cbm_store_free_edges(edges, nedges);
742743
cbm_store_free_nodes(consts, nconst);

0 commit comments

Comments
 (0)