CI R384: GCC ASan stack-use-after-scope in V3 annotation_stack memo type descriptors

Open
#32,741 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
22/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
compilers

Research direction

Start with vlib/v/types/annotation_stack_test.v and the failing command ./v -cc gcc -cflags -fsanitize=address ... vlib/v/types/annotation_stack_test.v, then generate the generated C with -keepc to find the __addr_2 stack object. Work out how the memo keeps a pointer to a temporary Type(int_) that outlives its initializer, which needs compiler and type-checker knowledge. Done means the exact ASan command passes without suppressing the check, skipping the test, or reducing the depth.

Written by the indexing model from the issue text.

Description

Executed master-CI failure (R384 — distinct from R380's strdup leak and R365's nested-map heap UAF)

  • Revision: f60a27d4b072e47dda80a21db0af579106ce0a11 (November 22, 2026); the parent workflow was still queued but this underlying job actually executed and failed.
  • Job: Linux GCC AddressSanitizer shard 2, job 137163735121, finished 2026-11-22 13:18:15 UTC; 1 failed, 1,385 passed, 163 skipped in shard 3/4 summary.
  • Exact repro from hosted log: ./v -cc gcc -cflags -fno-omit-frame-pointer -cflags -fsanitize=address -silent vlib/v/types/annotation_stack_test.v.
  • Actual trace: AddressSanitizer: stack-use-after-scope, READ 8 in types__mixed_integer_expr_type_can_widen → TypeChecker__widen_mixed_integer_expr_type → resolve_type_slow → annotate_node → test_annotation_walk_handles_deep_single_child_ast_iteratively. ASan identifies test-frame stack object __addr_2 (16 bytes), originating at generated-C line 150748; this is neither a compiler diagnostic fixture nor an external library false-positive.
  • Fixture: vlib/v/types/annotation_stack_test.v, unchanged between failing SHA and master 1173cc3c; both tests populate memo.types[i] = Type(int_). The memo stores references to types (storage_query.v dereferences *memo.types[mi]), so the inline sum-type value is implicitly address-taken and a temporary stack descriptor may outlive its initializer. This matches the observed __addr_2 expired stack object, but the precise generated C for this revision still needs inspection before definitive attribution.
  • Current applicability: unchanged test and type-checker implementation on descendant master; no matching validated fix found in targeted issue/PR search. A passed different ASan shard, queue state or unrelated newer master commit cannot close this.

Focused next actions

  1. Generate and retain GCC-ASan -keepc for the original fixture and identify __addr_2 assignment and use; verify memo holds a pointer to temporary Type(int_).
  2. Keep an int_type := Type(int_) descriptor in function scope in each fixture and store &int_type into memo entries, preserving the 20k-depth test, sibling test and all assertions; prove before/after under native GCC ASan with detect_stack_use_after_return as available and Clang ASan/MSan control.
  3. Run ./v self, ./v fmt -w vlib/v/types/annotation_stack_test.v, the exact command, V compiler/type checker tests, and uninstrumented control. Do not suppress ASan, skip the test, or reduce depth.
  4. Only mark verified-resolved when an actually executed matching corrected test/shard succeeds on patched revision/descendant.
Validation provenance

This record is based on the full hosted original log, source comparison, and a pointer-lifetime code inspection. No patched native V execution yet.

[!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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vlang/v

All issues in vlang/v

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.