ziglang/zig
259
6.0k
Fork
You've already forked zig
773

std.log.info panics after loading a c library #30879

Open
opened 2026年01月18日 10:31:58 +01:00 by scixor · 6 comments
Contributor
Copy link

Zig Version

0.16.0-dev.2223+4f16e80ce

Steps to Reproduce and Observed Behavior

When I try to run std.log.info after glfwinit...

conststd=@import("std");constc=@cImport(@cInclude("GLFW/glfw3.h"));pubfnmain()void{// std.debug.print("", .{}); // Somehow this fixes it?_=c.glfwInit();std.log.info("Hello",.{});// PANIC}
zig build-exe repro.zig -lc -lglfw && ./repro

panics with:

thread 114247 panic: attempt to use null value
aborting due to recursive panic
fish: Job 2, './repro' terminated by signal SIGABRT (Abort)

From what i saw it panics at
https://codeberg.org/ziglang/zig/src/branch/master/lib/std/Io/Threaded.zig#L13214

I have no experience in zig's codebase. My guess is it has something to do with environment

LD_DEBUG=bindings ./repro 2>&1 | grep setenv

there are a few setenvs which might cause relocation as many c libraries do like glfw ... and from I could tell, the environment pointer is stored at the start might go stale when scanEnviron tries to read it. That's why I assume std.debug.print before it fixes it. because then scanEnviron exits early once initlialized...

Not sure though : ) just eyeballed it.

Expected Behavior

There is should be no panic, it didn't happen before in zig so I assume this a regression.

### Zig Version 0.16.0-dev.2223+4f16e80ce ### Steps to Reproduce and Observed Behavior When I try to run `std.log.info` after `glfwinit`... ```zig const std = @import("std"); const c = @cImport(@cInclude("GLFW/glfw3.h")); pub fn main() void { // std.debug.print("", .{}); // Somehow this fixes it? _ = c.glfwInit(); std.log.info("Hello", .{}); // PANIC } ``` ```bash zig build-exe repro.zig -lc -lglfw && ./repro ``` panics with: ``` thread 114247 panic: attempt to use null value aborting due to recursive panic fish: Job 2, './repro' terminated by signal SIGABRT (Abort) ``` From what i saw it panics at https://codeberg.org/ziglang/zig/src/branch/master/lib/std/Io/Threaded.zig#L13214 I have no experience in zig's codebase. My guess is it has something to do with environment ```bash LD_DEBUG=bindings ./repro 2>&1 | grep setenv ``` there are a few `setenv`s which might cause relocation as many c libraries do like `glfw` ... and from I could tell, the environment pointer is stored at the [start](https://codeberg.org/ziglang/zig/src/branch/master/lib/std/start.zig#L625 ) might go stale when [scanEnviron](https://codeberg.org/ziglang/zig/src/branch/master/lib/std/Io/Threaded.zig#L13134-L13139) tries to read it. That's why I assume `std.debug.print` before it fixes it. because then `scanEnviron` exits early once initlialized... Not sure though : ) just eyeballed it. ### Expected Behavior There is should be no panic, it didn't happen before in zig so I assume this a regression.

I was also just experiencing this with 0.16 release and SDL
If I log.debug or anything before c.SDL_CreateWindow, all is fine. If I log immediately afterwards, I get this

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff6fe56c0 (LWP 744824)]
[New Thread 0x7fffe5fff6c0 (LWP 744831)]
[New Thread 0x7fffe566f6c0 (LWP 744832)]
thread 744822 panic: attempt to use null value
^C
Thread 1 "splitter" received signal SIGINT, Interrupt.
0x000000000120cef7 in os.linux.x86_64.syscall4 (number=futex, arg1=24952248, arg2=128, arg3=2, arg4=0)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/os/linux/x86_64.zig:40
40 return asm volatile ("syscall"
(gdb) bt
#0 0x000000000120cef7 in os.linux.x86_64.syscall4 (number=futex, arg1=24952248, arg2=128, arg3=2, 
 arg4=0) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/os/linux/x86_64.zig:40
#1 0x000000000120cc51 in os.linux.futex_4arg (
 uaddr=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>, futex_op=..., val=2, 
 timeout=0x0) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/os/linux.zig:753
#2 0x000000000120c592 in Io.Threaded.Thread.futexWaitInner (
 ptr=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>, expect=2, uncancelable=true, 
 timeout_ns=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:987
#3 0x000000000120b270 in Io.Threaded.Thread.futexWaitUncancelable (
 ptr=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>, expect=2, 
 timeout_ns=<error reading variable: Cannot access memory at address 0x2>)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:933
#4 0x000000000120b1fd in Io.Threaded.mutexLock (
 m=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:18736
#5 0x0000000001208ae1 in Io.Threaded.scanEnviron (
 t=0x17cb980 <Io.Threaded.global_single_threaded_instance>)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:14800
#6 0x0000000001208ba9 in Io.Threaded.environString__anon_13415 (
 t=0x17cb980 <Io.Threaded.global_single_threaded_instance>)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:16926
#7 0x000000000120558d in debug.ElfFile.DebugInfoSearchPaths.native (exe_path=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/ElfFile.zig:73
#8 0x00000000011f90e4 in debug.SelfInfo.Elf.Module.loadElf (mod=0x7ffff7656a98, gpa=..., io=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/SelfInfo/Elf.zig:347
#9 0x00000000011f8a27 in debug.SelfInfo.Elf.Module.getLoadedElf (mod=0x7ffff7656a98, gpa=..., io=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/SelfInfo/Elf.zig:330
#10 0x000000000119d6b8 in debug.SelfInfo.Elf.getSymbols (
 si=0x17cb8f8 <debug.getSelfDebugInfo.S.self_info>, io=..., symbol_allocator=..., text_arena=..., 
 address=18910402, resolve_inline_callers=true, symbols=0x7fffffff8b90)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/SelfInfo/Elf.zig:48
#11 0x000000000118de88 in debug.printSourceAtAddress (io=..., text_arena=0x7fffffff8ed0, 
 debug_info=0x17cb8f8 <debug.getSelfDebugInfo.S.self_info>, t=..., options=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:1205
#12 0x000000000118da51 in debug.writeCurrentStackTrace (options=..., t=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:778
#13 0x000000000118c933 in debug.defaultPanic (msg=..., first_trace_addr=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:568
#14 0x0000000001193249 in debug.FullPanic((function 'defaultPanic')).unwrapNull ()
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:134
#15 0x0000000001208cc3 in Io.Threaded.Environ.scan (
 environ=0x17cbd40 <Io.Threaded.global_single_threaded_instance+960>, allocator=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:314
#16 0x0000000001208b1b in Io.Threaded.scanEnviron (
 t=0x17cb980 <Io.Threaded.global_single_threaded_instance>)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:14803
#17 0x0000000001273344 in Io.Threaded.initLockedStderr (
 t=0x17cb980 <Io.Threaded.global_single_threaded_instance>, terminal_mode=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:13821
#18 0x0000000001273a4c in Io.Threaded.lockStderr (
 userdata=0x17cb980 <Io.Threaded.global_single_threaded_instance>, terminal_mode=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:13798
#19 0x0000000001244733 in Io.lockStderr (io=..., buffer=..., terminal_mode=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io.zig:2440
#20 0x00000000012444dd in debug.lockStderr (buffer=...)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:286
#21 0x0000000001391ff6 in log.defaultLog__anon_58431 ()
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/log.zig:106
#22 0x0000000001391b89 in log.log__anon_58429 ()
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/log.zig:72
#23 0x00000000013919f9 in log.scoped(.ui_sdl_imgui).debug__anon_34773 ()
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/log.zig:175
#24 0x00000000012c20bf in backends.sdl_imgui.Window.init (gpa=..., opts=...)
 at /home/actondev/dev/actondev/remvon/libs/ui/backends/sdl_imgui.zig:137
#25 0x00000000012ca0e1 in splitter.main (init=...) at splitter.zig:101
#26 0x00000000012caed2 in start.callMain ()
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/start.zig:737
#27 start.callMainWithArgs () at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/start.zig:638
#28 start.main (c_argc=1, c_argv=0x7fffffffe0d8, c_envp=0x7fffffffe0e8)
 at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/start.zig:663
(gdb) 

I'm in the middle of updating from 0.15 and this is a bumper. At least for now I can do the workaround of logging something before

I was also just experiencing this with 0.16 release and SDL If I log.debug or anything before `c.SDL_CreateWindow`, all is fine. If I log immediately afterwards, I get this ``` [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". [New Thread 0x7ffff6fe56c0 (LWP 744824)] [New Thread 0x7fffe5fff6c0 (LWP 744831)] [New Thread 0x7fffe566f6c0 (LWP 744832)] thread 744822 panic: attempt to use null value ^C Thread 1 "splitter" received signal SIGINT, Interrupt. 0x000000000120cef7 in os.linux.x86_64.syscall4 (number=futex, arg1=24952248, arg2=128, arg3=2, arg4=0) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/os/linux/x86_64.zig:40 40 return asm volatile ("syscall" (gdb) bt #0 0x000000000120cef7 in os.linux.x86_64.syscall4 (number=futex, arg1=24952248, arg2=128, arg3=2, arg4=0) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/os/linux/x86_64.zig:40 #1 0x000000000120cc51 in os.linux.futex_4arg ( uaddr=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>, futex_op=..., val=2, timeout=0x0) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/os/linux.zig:753 #2 0x000000000120c592 in Io.Threaded.Thread.futexWaitInner ( ptr=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>, expect=2, uncancelable=true, timeout_ns=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:987 #3 0x000000000120b270 in Io.Threaded.Thread.futexWaitUncancelable ( ptr=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>, expect=2, timeout_ns=<error reading variable: Cannot access memory at address 0x2>) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:933 #4 0x000000000120b1fd in Io.Threaded.mutexLock ( m=0x17cbdb8 <Io.Threaded.global_single_threaded_instance+1080>) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:18736 #5 0x0000000001208ae1 in Io.Threaded.scanEnviron ( t=0x17cb980 <Io.Threaded.global_single_threaded_instance>) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:14800 #6 0x0000000001208ba9 in Io.Threaded.environString__anon_13415 ( t=0x17cb980 <Io.Threaded.global_single_threaded_instance>) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:16926 #7 0x000000000120558d in debug.ElfFile.DebugInfoSearchPaths.native (exe_path=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/ElfFile.zig:73 #8 0x00000000011f90e4 in debug.SelfInfo.Elf.Module.loadElf (mod=0x7ffff7656a98, gpa=..., io=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/SelfInfo/Elf.zig:347 #9 0x00000000011f8a27 in debug.SelfInfo.Elf.Module.getLoadedElf (mod=0x7ffff7656a98, gpa=..., io=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/SelfInfo/Elf.zig:330 #10 0x000000000119d6b8 in debug.SelfInfo.Elf.getSymbols ( si=0x17cb8f8 <debug.getSelfDebugInfo.S.self_info>, io=..., symbol_allocator=..., text_arena=..., address=18910402, resolve_inline_callers=true, symbols=0x7fffffff8b90) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug/SelfInfo/Elf.zig:48 #11 0x000000000118de88 in debug.printSourceAtAddress (io=..., text_arena=0x7fffffff8ed0, debug_info=0x17cb8f8 <debug.getSelfDebugInfo.S.self_info>, t=..., options=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:1205 #12 0x000000000118da51 in debug.writeCurrentStackTrace (options=..., t=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:778 #13 0x000000000118c933 in debug.defaultPanic (msg=..., first_trace_addr=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:568 #14 0x0000000001193249 in debug.FullPanic((function 'defaultPanic')).unwrapNull () at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:134 #15 0x0000000001208cc3 in Io.Threaded.Environ.scan ( environ=0x17cbd40 <Io.Threaded.global_single_threaded_instance+960>, allocator=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:314 #16 0x0000000001208b1b in Io.Threaded.scanEnviron ( t=0x17cb980 <Io.Threaded.global_single_threaded_instance>) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:14803 #17 0x0000000001273344 in Io.Threaded.initLockedStderr ( t=0x17cb980 <Io.Threaded.global_single_threaded_instance>, terminal_mode=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:13821 #18 0x0000000001273a4c in Io.Threaded.lockStderr ( userdata=0x17cb980 <Io.Threaded.global_single_threaded_instance>, terminal_mode=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io/Threaded.zig:13798 #19 0x0000000001244733 in Io.lockStderr (io=..., buffer=..., terminal_mode=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/Io.zig:2440 #20 0x00000000012444dd in debug.lockStderr (buffer=...) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/debug.zig:286 #21 0x0000000001391ff6 in log.defaultLog__anon_58431 () at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/log.zig:106 #22 0x0000000001391b89 in log.log__anon_58429 () at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/log.zig:72 #23 0x00000000013919f9 in log.scoped(.ui_sdl_imgui).debug__anon_34773 () at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/log.zig:175 #24 0x00000000012c20bf in backends.sdl_imgui.Window.init (gpa=..., opts=...) at /home/actondev/dev/actondev/remvon/libs/ui/backends/sdl_imgui.zig:137 #25 0x00000000012ca0e1 in splitter.main (init=...) at splitter.zig:101 #26 0x00000000012caed2 in start.callMain () at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/start.zig:737 #27 start.callMainWithArgs () at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/start.zig:638 #28 start.main (c_argc=1, c_argv=0x7fffffffe0d8, c_envp=0x7fffffffe0e8) at /home/actondev/dev/zig-x86_64-linux-0.16.0/lib/std/start.zig:663 (gdb) ``` I'm in the middle of updating from 0.15 and this is a bumper. At least for now I can do the workaround of logging something before
Contributor
Copy link

I cannot reproduce this on 0.16.0 nor on 0.17.0-dev.619+f3a7a4c5e.

// main.zigconststd=@import("std");externfnglfwInit()c_int;pubfnmain()void{constval=glfwInit();std.log.info("the retval is {d}",.{val});// works fine}
$ zig run ./main.zig -lc -lglfw && zigst3 run ./main.zig -lc -lglfw
info: the retval is 1
info: the retval is 1
I cannot reproduce this on `0.16.0` nor on `0.17.0-dev.619+f3a7a4c5e`. ```zig // main.zig const std = @import("std"); extern fn glfwInit() c_int; pub fn main() void { const val = glfwInit(); std.log.info("the retval is {d}", .{val}); // works fine } ``` ``` $ zig run ./main.zig -lc -lglfw && zigst3 run ./main.zig -lc -lglfw info: the retval is 1 info: the retval is 1 ```

indeed I don't notice this with glfw & this example.

But, this one panics for me (0.17)

conststd=@import("std");externfnSDL_CreateWindow(title:[*c]constu8,w:c_int,h:c_int,flags:c_int)?*anyopaque;pubfnmain()!void{_=SDL_CreateWindow("foo",400,200,0);std.log.info("hello",.{});}
indeed I don't notice this with glfw & this example. But, this one panics for me (0.17) ```zig const std = @import("std"); extern fn SDL_CreateWindow(title: [*c]const u8, w: c_int, h: c_int, flags: c_int) ?*anyopaque; pub fn main() !void { _ = SDL_CreateWindow("foo", 400, 200, 0); std.log.info("hello", .{}); } ```
Author
Contributor
Copy link

@mercenary your snippet

// main.zigconststd=@import("std");externfnglfwInit()c_int;pubfnmain()void{constval=glfwInit();std.log.info("the retval is {d}",.{val});// works fine}

still fails for me with

thread 196219 panic: attempt to use null value

when compiled with

zig build-exe main.zig -lc -lglfw && ./main
# and 
zig run ./main.zig -lc -lglfw

This is on 0.17.0-dev.420+8086ae176

this is the ldd output so it does link with glfw (just for info)

	linux-vdso.so.1 (0x00007884a4c1a000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007884a4ae3000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007884a4800000)
	/lib64/ld-linux-x86-64.so.2 (0x00007884a4c1c000)
	libglfw.so.3 => /lib/x86_64-linux-gnu/libglfw.so.3 (0x00007884a4a5a000)

I am not sure why it would work on yours and fail on mine... my guess it because the env pointer goes stale because it reallocates. You can try see LD_DEBUG=bindings ./main 2>&1 | rg "setenv" not sure if it helps

@mercenary your snippet ```zig // main.zig const std = @import("std"); extern fn glfwInit() c_int; pub fn main() void { const val = glfwInit(); std.log.info("the retval is {d}", .{val}); // works fine } ``` still fails for me with ``` thread 196219 panic: attempt to use null value ``` when compiled with ```bash zig build-exe main.zig -lc -lglfw && ./main # and zig run ./main.zig -lc -lglfw ``` This is on `0.17.0-dev.420+8086ae176` this is the ldd output so it does link with glfw (just for info) ``` linux-vdso.so.1 (0x00007884a4c1a000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007884a4ae3000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007884a4800000) /lib64/ld-linux-x86-64.so.2 (0x00007884a4c1c000) libglfw.so.3 => /lib/x86_64-linux-gnu/libglfw.so.3 (0x00007884a4a5a000) ``` I am not sure why it would work on yours and fail on mine... my guess it because the env pointer goes stale because it reallocates. You can try see `LD_DEBUG=bindings ./main 2>&1 | rg "setenv"` not sure if it helps

I failed to reproduce this on 0.17.0-dev.4049+2153f8143. I tried both the first repro with GLFW and manually forcing env to realloc:

void env_realloc(void) {
 for (int i = 0; i < 1000; i++) {
 char key[32], val[64];
 snprintf(key, sizeof(key), "FOO_BAR_%d", i);
 snprintf(val, sizeof(val), "foo_bar_baz_bar_foo_bar_baz_bar_foo_bar_%d", i);
 setenv(key, val, 1);
 }
 }
conststd=@import("std");constc=@import("c");externvarenviron:[*][*:0]u8;pubfnmain()void{constbefore=environ;c.env_realloc();constafter=environ;std.log.info("{}",.{before==after});}

prints info: false and exits with no panic

I failed to reproduce this on `0.17.0-dev.4049+2153f8143`. I tried both the first repro with GLFW and manually forcing env to realloc: ```c void env_realloc(void) { for (int i = 0; i < 1000; i++) { char key[32], val[64]; snprintf(key, sizeof(key), "FOO_BAR_%d", i); snprintf(val, sizeof(val), "foo_bar_baz_bar_foo_bar_baz_bar_foo_bar_%d", i); setenv(key, val, 1); } } ``` ```zig const std = @import("std"); const c = @import("c"); extern var environ: [*][*:0]u8; pub fn main() void { const before = environ; c.env_realloc(); const after = environ; std.log.info("{}", .{before==after}); } ``` prints `info: false` and exits with no panic
Author
Contributor
Copy link

Quite weird, the debugger does fail at /lib/std/Io/Threaded.zig:314:40 for me with opt_entry null....

image

just changing it in the standard library for me fixes it

- const entry = opt_entry.?;
+ const entry = opt_entry orelse continue;
./main 
info: the retval is 1

But obviously that's not the root cause. I just haven't been able to sit down and find the main cause.

Quite weird, the debugger does fail at `/lib/std/Io/Threaded.zig:314:40` for me with `opt_entry` null.... ![image](/attachments/a147d864-bc4e-457f-8d93-9119e457915e) just changing it in the standard library for me fixes it ```diff - const entry = opt_entry.?; + const entry = opt_entry orelse continue; ``` ``` ./main info: the retval is 1 ``` But obviously that's not the root cause. I just haven't been able to sit down and find the main cause.
210 KiB
Sign in to join this conversation.
No Branch/Tag specified
master
elfv2
spork8
restricted
0.16.x
panic-rewrite
parking-futex-lockfree
windows-Io-cleanup
Io-watch
ParseCommandLineOptions
windows-async-files
poll-ring
debug-file-leaks-differently
debug-file-leaks
ProcessPrng
elfv2-dyn
jobserver
threadtheft
io-threaded-no-queue
0.15.x
Io.net
comptime-allocator
restricted-function-pointers
cli
wasm-linker-writer
wrangle-writer-buffering
sha1-stream
async-await-demo
fixes
0.14.x
ast-node-methods
macos-debug-info
make-vs-configure
fuzz-macos
sans-aro
ArrayList-reserve
incr-bug
llvm-ir-nosanitize-metadata
ci-tarballs
ci-scripts
threadpool
0.12.x
new-pkg-hash
json-diagnostics
more-doctests
rework-comptime-mutation
0.11.x
ci-perf-comment
stage2-async
0.10.x
autofix
0.9.x
aro
hcs
0.8.x
0.7.x
0.16.0
0.15.2
0.15.1
0.15.0
0.14.1
0.14.0
0.12.1
0.13.0
0.12.0
0.11.0
0.10.1
0.10.0
0.9.1
0.9.0
0.8.1
0.8.0
0.7.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.1
0.1.0
Labels
Clear labels
abi/f32
abi/ilp32
abi/sf
accepted
This proposal is planned.
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
The web application for interactive documentation and generation of its assets.
backend/c
The C backend outputs C source code.
backend/llvm
The LLVM backend outputs an LLVM bitcode module.
backend/self-hosted
The self-hosted backends produce machine code directly.
binutils
Zig's included binary utilities: zig ar, zig dlltool, zig lib, zig ranlib, zig objcopy, and zig rc.
breaking
Implementing this issue could cause existing code to no longer compile or have different behavior.
build system
The Zig build system - zig build, std.Build, the build runner, and package management.
debug info
An issue related to debug information (e.g. DWARF) produced by the Zig compiler.
docs
An issue with documentation, e.g. the language reference or standard library doc comments.
error message
This issue points out an error message that is unhelpful and should be improved.
frontend
Tokenization, parsing, AstGen, ZonGen, Sema, Legalize, and Liveness.
fuzzing
An issue related to Zig's integrated fuzz testing.
incremental
Reuse of internal compiler state for faster compilation.
lib/c
This issue relates to Zig's libc implementation and/or vendored libcs.
lib/compiler-rt
This issue relates to Zig's compiler-rt library.
lib/cxx
This issue relates to Zig's vendored libc++ and/or libc++abi.
lib/std
This issue relates to Zig's standard library.
lib/tsan
This issue relates to Zig's vendored libtsan.
lib/ubsan-rt
This issue relates to Zig's ubsan-rt library.
lib/unwind
This issue relates to Zig's vendored libunwind.
linking
Zig's integrated object file and incremental linker.
miscompilation
The compiler reports success but produces semantically incorrect code.
os/android
os/contiki
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hermit
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
This issue suggests language modifications. If it also has the "accepted" label then it is planned.
release notes
This issue or pull request should be mentioned in the release notes.
testing
This issue is related to testing the compiler, standard library, or other parts of Zig.
zig cc
Zig as a drop-in C-family compiler.
zig fmt
The Zig source code formatter.
zig reduce
The Zig source code reduction tool.
bounty
https://ziglang.org/news/announcing-donor-bounties
bug
Observed behavior contradicts documented or intended behavior.
contributor-friendly
This issue is limited in scope and/or knowledge of project internals.
downstream
An issue with a third-party project that uses this project.
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
infra
An issue related to project infrastructure, e.g. continuous integration.
optimization
A task to improve performance and/or resource usage.
question
No questions on the issue tracker; use a community space instead.
regression
Something that used to work in a previous version stopped working
upstream
An issue with a third-party project that this project uses.
use case
Describes a real use case that is difficult or impossible, but does not propose a solution.
No labels
abi/f32
abi/ilp32
abi/sf
accepted
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
backend/c
backend/llvm
backend/self-hosted
binutils
breaking
build system
debug info
docs
error message
frontend
fuzzing
incremental
lib/c
lib/compiler-rt
lib/cxx
lib/std
lib/tsan
lib/ubsan-rt
lib/unwind
linking
miscompilation
os/android
os/contiki
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hermit
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
release notes
testing
zig cc
zig fmt
zig reduce
bounty
bug
contributor-friendly
downstream
enhancement
infra
optimization
question
regression
upstream
use case
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglang/zig#30879
Reference in a new issue
ziglang/zig
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?