Skip to content

panic: switch on corrupt value running code generated by self-hosted x86_64 backend #21834

Description

@ehaas

Zig Version

0.14.0-dev.2050+4adf63aef

Steps to Reproduce and Observed Behavior

uname -a output: Linux system76-pc 6.9.3-76060903-generic #202405300957~1726766035~22.04~4092a0e~dev-Ubuntu SMP PREEMPT_DY x86_64 x86_64 x86_64 GNU/Linux

const std = @import("std");
pub fn main() !void {
    const query = try std.Target.Query.parse(.{ .arch_os_abi = "x86-netbsd.6.99" });
    _ = try std.zig.system.resolveTargetQuery(query);
}

Run with: zig run -fno-llvm test.zig

thread 8143 panic: switch on corrupt value
Unwind error at address `exe:0x103d8fb` (error.InvalidDebugInfo), trace may be incomplete

/home/ehaas/.local/zig-linux-x86_64-0.14.0-dev.2050+4adf63aef/lib/std/zig/system.zig:321:45: 0x10206bc in resolveTargetQuery (std.zig)
    if (query.os_version_max) |max| switch (max) {
                                            ^
/home/ehaas/test.zig:4:46: 0x101abb0 in main (test.zig)
    _ = try std.zig.system.resolveTargetQuery(query);
                                             ^
/home/ehaas/.local/zig-linux-x86_64-0.14.0-dev.2050+4adf63aef/lib/std/start.zig:618:37: 0x101b1a5 in posixCallMainAndExit (std.zig)
            const result = root.main() catch |err| {
                                    ^
/home/ehaas/.local/zig-linux-x86_64-0.14.0-dev.2050+4adf63aef/lib/std/start.zig:249:5: 0x1018016 in _start (std.zig)
    asm volatile (switch (native_arch) {
    ^

Expected Behavior

No output (this is what happens using the LLVM backend).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions