ASan: translated fixed [9]i8 struct field reads 9 bytes from c'local' (6-byte C literal)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start with vlib/v/gen/c/struct.v, in gen_struct_init_with_fixed_array_fields_impl and write_fixed_field_copy, and check why gen_fixed_array_copy_source falls back to sizeof(destination) for short c'...' literals. Reproduce with ./v -cc gcc -cflags -fsanitize=address -silent vlib/v/tests/translated_c_string_fixed_char_array_struct_init_test.v after ./v self, and inspect the output of -keepc. Done when that test passes under GCC and Clang ASan with the assertions unchanged and a regression test added.
Written by the indexing model from the issue text.
Description
Executed master CI failure (R363)
Master d8083d40873efc7689abdb15f4ca21b4f5d59f4a — GCC ASan vlib shard 2, job 136897142365, completed 2026-11-21 18:35 UTC while the parent workflow was still queued. After 1,270 passed / 186 skipped, the executed vlib/v/tests/translated_c_string_fixed_char_array_struct_init_test.v failed test_translated_c_string_initializes_local_fixed_char_array_fields with AddressSanitizer global-buffer-overflow: memcpy READ9 immediately after 6-byte global literal "local". This is a Cgen/runtime memory-safety error, not a timeout, setup failure, or intentional failing fixture.
Reproduce the original hosted command: ./v -cc gcc -cflags -fno-omit-frame-pointer -cflags -fsanitize=address -silent vlib/v/tests/translated_c_string_fixed_char_array_struct_init_test.v.
Source and suspected mechanism
The entire fixture is byte-identical between failing SHA and the inspected 4b4f8c2b master (blob 422e50865e1658117e24bc560b9111df6a22edab). It sets short_name: c'local' in FixedNames where SignedNameAlias = [9]i8, and asserts indices 4 and 5 (l, NUL). vlib/v/gen/c/struct.v gen_struct_init_with_fixed_array_fields_impl emits per-field copies using write_fixed_field_copy; that function is designed to copy min(sizeof(C string literal), sizeof(destination)) for a bare quoted source, but defaults to sizeof(destination) for all other emitted expressions. A cast/wrapper from signed-char or alias lowering, or another Cgen branch, could bypass its literal detection. The precise generated C source was not retained in the job; that discriminator remains unproved.
Local discriminator (C-only, not V validation)
I independently compiled a GCC14 C11/ASan analogue. memcpy(short_name, "local", sizeof(short_name)) (9 bytes) produced the same global-buffer-overflow READ9 and exit1; limiting the copy to min(sizeof("local"), sizeof(short_name)) passed exit0. This demonstrates the C memory rule but does not validate V's generated C, type/alias recognition, or a compiler patch.
Required correction and validation
- Rebuild current
./v self, inspect-keepc -cgoutput for the original fixture; print both the original AST value node kind/type andgen_fixed_array_copy_sourcerendered expression, and determine why the literal-size branch is bypassed. - Correct only the applicable Cgen path so short
c'...'literals zero-pad fixed[N]i8/char/u8 struct fields, even through aliases/wrappers; do not trim raw fixed-array expressions whose full size is known. Preserve all existing fixture assertions andexact/UTF-8/escaped/heap/global cases; add a regression for the precise transformed source shape. - Repeat the original GCC ASan command, Clang ASan, focused V test/format, and
./v selfon the patched revision. No disabling the sanitizer, skipping the test, or weakening assertions.
Status UNRESOLVED / STILL APPLICABLE. No overlap found in searched existing PRs/issues for this exact executed fixture, no V toolchain available locally, no speculative merge.
[!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