Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malformed extern fn decl containing slice causes segfault rather than error message #22977

Open
paperdev-code opened this issue Feb 22, 2025 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@paperdev-code
Copy link

Zig Version

0.14.0-dev.3286+05d8b565a

Steps to Reproduce and Observed Behavior

given the following code;

//                     v- is bad
extern const bad: fn ([]const u8) void;
pub fn main() void {
    bad();
}

attempt at compilation;

❯ zig run test.zig
Error: nu::shell::terminated_by_signal
└─ mem.sliceAsBytes__anon_19529
  × External command was terminated by a signal
   ╭─[entry #12:1:1]
 1 │ zig run test2.zig
   · ─┬─
   ·  ╰── terminated by SIGSEGV (11)
   ╰────

Expected Behavior

expect the output to be similar to;

//             v- is bad
extern fn bad([]const u8) void;
pub fn main() void {
    bad();
}

which produces;

❯ zig run test2.zig
test2.zig:2:15: error: parameter of type '[]const u8' not allowed in function with calling convention 'x86_64_sysv'
extern fn bad([]const u8) void;
              ^~~~~~~~~~
test2.zig:2:15: note: slices have no guaranteed in-memory representation
referenced by:
    main: test2.zig:4:5
    posixCallMainAndExit: /nix/store/5ijjcxhqcjc96q0pkqrnh97mkxpcqvwg-zig-0.14.0-dev.3286+05d8b565a/lib/std/start.zig:647:22
    4 reference(s) hidden; use '-freference-trace=6' to see all references
@paperdev-code paperdev-code added the bug Observed behavior contradicts documented or intended behavior label Feb 22, 2025
@paperdev-code paperdev-code changed the title malformed extern decl containing slice causes segfault rather than error message malformed extern fn decl containing slice causes segfault rather than error message Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant