andrewrk / zig-async-demo

Comparing concurrent code example programs between other languages and Zig
55 stars 9 forks source link

Getting segfaults & integer overflows from 10k zig iteration #3

Open kprotty opened 4 years ago

kprotty commented 4 years ago

When increasing the concurrency from 10 to 1000 as shown int the README, sieve.zig throws segfaults at different points in std over different runs, sometimes dead-locking.

Examples:

Segmentation fault at address 0x1
/usr/share/zig/lib/zig/std/atomic/queue.zig:0:0: 0x243acd in std.event.channel.Channel(u32).dispatch (run)
???:?:?: 0x7fd086a0aaa7 in ??? (???)
Segmentation fault at address 0x59
/usr/share/zig/lib/zig/std/event/channel.zig:164:17: 0x2437f3 in std.event.channel.Channel(u32).dispatch (run)
            _ = @atomicRmw(u8, &self.need_dispatch, .Xchg, 1, .SeqCst);
                ^
???:?:?: 0x7f80b0e5c74f in ??? (???)
Segmentation fault at address 0x7f4a00000002
/usr/share/zig/lib/zig/std/event/loop.zig:725:17: 0x244586 in std.event.loop.Loop.workerRun (run)
                resume next_tick_node.data;
                ^
integer overflow
andrewrk commented 4 years ago

Good finds. I think we're going to want to have comprehensive fuzz testing for the std lib event loop implementation.

andrewrk commented 4 years ago

These are also good use cases for adding some kind of language support for race detecting and multithreaded safety features.