Skip to content

Panic at start.zig when linking a C library: cast causes pointer to be null #17345

@TUSF

Description

@TUSF

Zig Version

0.12.0-dev.694+937e8cb70

Steps to Reproduce and Observed Behavior

Not entirely certain.

I have two repos, both Zig packages for C libraries. I've also ported over the code needed to run the original library's tests, and those work fine. However, I started working on some wrappers for a Zig API on them, and now things are weird when I try to run the tests.

More specifically, I was trying to get some basic tests going on my libcss package, and while the normal C tests (seem to) work fine, when I try to use the Zig tests (which don't actually have any tests yet) I get the following error:

$ zig build test
run test: error: thread 18381 panic: cast causes pointer to be null
/home/jere/zig/0.12.0-dev.694+937e8cb70/files/lib/std/start.zig:478:41: 0x23e8ed in main (test)
        const phdrs = (@as([*]elf.Phdr, @ptrFromInt(at_phdr)))[0..at_phnum];
                                        ^
???:?:?: 0x7f22fe9a9d8f in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7f22fe9a9d8f` was not available, trace may be incomplete


run test: error: the following command terminated with signal 6 (expected exited with code 0):
/mnt/j/code/projects/netsurf/libcss/zig-cache/o/5643e278783a8ad5a66a6a284332a371/test --listen=-
Build Summary: 171/173 steps succeeded; 1 failed (disable with --summary none)
test transitive failure
└─ run test failure

This seems to only be a problem when linking libc, and running the tests on Linux. (the tests run fine on Windows) However, I don't really know what the condition for this error is, because I have another package libwapcaplet (which libcss depends on) where this doesn't happen: the Zig test (which actually has one test) runs fine.

Expected Behavior

To start up properly without panicing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions