musl: embedded prealloc cross-snapshot fails on conflicting execinfo.h backtrace_symbols prototypes

Open
#32,705 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 the failing fixture in vlib/v/embed_file/tests/embed_file_cross_snapshot_test.v (test_cross_snapshot_runs_under_prealloc) and the C extern declarations for backtrace_symbols and backtrace_symbols_fd in vlib/builtin/builtin_backtraces_nix.c.v, then compare them with the included execinfo.h in the generated prog.c. Reproduce under the musl compiler setting with the generated C kept, and check vlib/v/gen/c/preamble_test.v for the expected signature. Done means the original fixture passes with no suppressed compiler errors, and a regression covers both system-header and headerless modes.

Written by the indexing model from the issue text.

Description

Executed master failure (not merely workflow status)
  • Master revision: d8083d40873efc7689abdb15f4ca21b4f5d59f4a.
  • Ubuntu musl: https://github.com/vlang/v/actions/runs/44918531732/job/136897140641 (completed 2026-11-21 17:08:56 UTC, after 1,435 vlib tests passed, 753 skipped, one executed failure).
  • Failing fixture: vlib/v/embed_file/tests/embed_file_cross_snapshot_test.v:472, test_cross_snapshot_runs_under_prealloc. Its nested cc -std=gnu11 -w -o prog prog.c -lm -lpthread exits 1 before the executable can run. This is a C prototype/ABI diagnostic, not a harness deadline, failed intentional fixture, or missing X11.
Exact compiler diagnostic

The generated prog.c includes /usr/include/execinfo.h (at line 3318) and then emits at lines 6517/6519:

char** backtrace_symbols(void** const_buffer, i32 size);
void backtrace_symbols_fd(void** const_buffer, i32 size, i32 fd);

The C system header declares char **backtrace_symbols(void *const *, int) and void backtrace_symbols_fd(void *const *, int, int). The void ** / void *const * difference is a function prototype conflict; adding -w does not suppress it.

Personally executed C-only discriminator with GCC 14 and #include <execinfo.h>: old generated-style prototypes fail gcc -std=gnu11 -fsyntax-only exit 1 with both conflicting type errors; accurate void *const * prototypes pass exit 0. This is not V compiler/native musl validation.

Source and applicability

vlib/builtin/builtin_backtraces_nix.c.v declares:

fn C.backtrace_symbols(a &voidptr, size i32) &&char
fn C.backtrace_symbols_fd(a &voidptr, size i32, fd i32)

That file's blob is c1844a136c64c87e43c5e115eaa64e304f7d7786 on both failing d808 and current master 1d8ff20033be7c4b39b2df9e4cd3a9900843efba. The V bindings' generated declarations disagree with the included native execinfo.h. Existing Cgen preamble test vlib/v/gen/c/preamble_test.v expects the correct void* const* signature in the target-libc preamble, so investigate duplicate V binding prototype generation and native-header ownership, not merely the libc preamble text. Related historic work: #32542 changes backtrace output but does not validate this nested musl fixture; #14250 supplies weak musl symbols, not a fix for conflicting prototypes.

Focused repair / validation next
  1. Under -cc musl-gcc -gc none -d use_bundled_libgc, reproduce the original embed_file_cross_snapshot_test.v, preserving -prealloc, 3 assertions and the snapshot's payload checksum. Keep generated prog.c with -keepc/-cg (or the test helper output).
  2. Fix the actual C prototype/header ownership so there is no incompatible redeclaration when <execinfo.h> is present. Preserve proper headerless declarations and native platform signatures on Linux/glibc, musl, macOS, and BSD rather than dropping necessary symbols globally.
  3. Add a native V regression for both system-header and headerless modes and test original musl embed cross-snapshot plus ./v self, format, focused builtin/preamble tests, and the original failing integration. Do not skip the test or suppress compiler errors.

Status: unresolved / still applicable. Exact hosted descendant regression and local V toolchain unavailable in this investigation; no repair or green claim 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.