V3 nested-map append duplicates previous array element on Clang MemorySanitizer (staged owned RHS)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 12/100
Research direction
Start at vlib/v/transform/map.v, function lower_map_index_append_with_info_and_prelude around lines 3510-3615, then the failing assertion at vlib/v/tests/nested_map_mutation_missing_outer_key_test.v:510. Rebuild with ./v self and reproduce the minimal case appending [3,4] then [5,6] to a nested map, comparing literal, call and borrowed RHS and inspecting generated C map_append_rhs and array__push versus array__push_many. Done means the second element is [5,6] under Clang MSan and GCC/Clang without it, with a regression test added.
Written by the indexing model from the issue text.
Description
Executed master CI failure (not a queued/skipped result)
- Failing master d8083d40873efc7689abdb15f4ca21b4f5d59f4a; completed 2026-11-21 20:02 UTC.
- Clang MemorySanitizer job 136897142315, after 4,321 passing vlib tests / 762 skipped, one actual failing V test.
- Original invocation from job:
./v -cc clang -gc none -d use_bundled_libgc -cflags -fno-omit-frame-pointer -cflags -maes -cflags -mpclmul -cflags -fsanitize=memory -silent vlib/v/tests/nested_map_mutation_missing_outer_key_test.v. test_nested_append_releases_staged_owned_rhs, atvlib/v/tests/nested_map_mutation_missing_outer_key_test.v:510, expects[[3, 4], [5, 6]], actually gets[[3, 4], [3, 4]]. This is a logical value error, not an MSan use-of-uninitialized-memory diagnostic, a GitHub job timeout, or an intentionally failing test.
Source comparison and constrained hypothesis
The original test file has the same blob SHA 9ce67b59932adc686bd1571ffd7655c09987b5b8 on the failing revision and current master inspected 9621aa02fd7d7788700846e93242d08bd70a8aea. The fixture first appends make_nested_append_row() and then a literal [5, 6] to map[string]map[string][][]int; the second append repeats the first element.
Inspect vlib/v/transform/map.v lower_map_index_append_with_info_and_prelude (about lines 3510–3615): nested map RHS is staged to map_append_rhs before re-acquiring inner-map storage. The helper marks array literals as owned, creates append_rhs = t.make_ident(staged_rhs_name), annotates << as scalar vs push-many, then clones/releases staged RHS depending on mode. The explicit set_node_typ applied only later to cleanup identifiers is worth checking against annotate_left_shift's type selection; this is an unverified hypothesis, not a proven bug. The value could also be corrupted by array-copy ownership or storage aliasing. stable_map_lvalue_for_reuse and map_index_inner_map_slot re-acquire the stored inner map after staging; inspect that sequence too.
Minimal native discriminator and safe fix requirements
- Rebuild V on current master:
./v self. Run the original test with the exact Clang MSan command,MSAN_OPTIONS=track_origins=2, and-keepc -cg(or V's equivalent generated-C preservation). Also test GCC and Clang without MSan. - Reduce to
mut rows := map[string]map[string][][]int{}; rows['a']['b'] << [3,4]; rows['a']['b'] << [5,6]. Contrast literal RHS withfn mk() []int { return [5,6] }andx := [5,6]; rows['a']['b'] << x. Check generated Cmap_append_rhstype/value, emittedarray__pushversusarray__push_many, copy/cloning, release order, and resulting pointer/length/capacity. - Fix the proven storage/type ordering error minimally in V3 transform/Cgen. Add regression for two different scalar array elements in a nested map, literal versus call versus borrowed RHS, verify no aliasing/use-after-free under Clang MSan and GCC/Clang ASan, preserving current assertions.
- After compiler changes run
./v self,./v fmtfor modified files, compiler-errors, focused transform/map and original vlib test on the patched revision. No skip, assertion weakening or suppressions.
Status: unresolved / investigating, currently applicable as fixture unchanged; original native patched execution not yet available. Related older map families are not proof of this specific source corruption.
[!NOTE]
You can use the 👍 reaction to increase the issue's priority for developers.Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
- Dominant language
- V
- Stars
- 38.1k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 682
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vlang/v
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sagemathinc/sagebrush#1683 ·
Maintainers usually reply within 1 day
-
bot-triaged module: aotinductor module: compile-time module: inductor module: performance module: rocm oncall: export oncall: pt2 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
baseballyama/rsvelte#5235 ·
Maintainers usually reply within 1 day
-
lang-core: member access on a component instance reads its internal fields instead of giving nullOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
midspiral/LemmaScript#355 · 1 comment ·
Maintainers usually reply within 1 day