-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Build issue on Ubuntu #14
Comments
you have to add thread 1670123 panic: index out of bounds: index 51135, len 6552
/home/sweet/repos/DOOM-fire-zig/src/main.zig:623:39: 0x103e193 in showDoomFire (DOOM-fire)
spread_px = screen_buf[doFire_idx];
^
/home/sweet/repos/DOOM-fire-zig/src/main.zig:695:17: 0x103b5e9 in main (DOOM-fire)
showDoomFire();
^
/usr/lib/zig/std/start.zig:524:37: 0x103b0fe in main (DOOM-fire)
const result = root.main() catch |err| {
^
???:?:?: 0x71a86cc38e07 in ??? (libc.so.6)
Unwind information for `libc.so.6:0x71a86cc38e07` was not available, trace may be incomplete
???:?:?: 0x71a86cc38ecb in ??? (libc.so.6)
???:?:?: 0x103ad44 in ??? (???)
zsh: IOT instruction (core dumped) ./zig-out/bin/DOOM-fire |
Thanks for reporting! I will do some sleuthing. |
Thanks @const-void . The follow diff fixes the build issues I hit on Ubuntu. I'm not sure if this also works on macOS & other supported platforms. index 2c1639c..29ece06 100644
--- a/build.zig
+++ b/build.zig
@@ -22,6 +22,8 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
+ exe.linkLibC();
+
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running `zig build`).
diff --git a/src/main.zig b/src/main.zig
index b2864e3..167136b 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -5,6 +5,7 @@
//
const builtin = @import("builtin");
const std = @import("std");
+const libc = @import("libc");
const allocator = std.heap.page_allocator; |
FYI, someone fixed the linux build and crash in a fork. At least this worked for me on Linux Mint 20.3, building w/ zig 0.13.0: |
Using multipass on OSX, adding LibC to compilation with a release mode results in a successful / operational DOOM-fire-zig. However, when in debug mode, there is a panic but alas, my very lazy error handling is not being very helpful. This will take me a moment or two to think about ... how should errors be handled and reported. |
I wonder if using a saturating operator would help prevent that? |
Adding a few choice std.debug.print("\n\nN: x = {d}, y = {d}\n", .{ doFire_x, doFire_y }); //++
while (doFire_x < FIRE_W) : (doFire_x = doFire_x + 1) {
doFire_y = 0;
while (doFire_y < FIRE_H) : (doFire_y += 1) {
std.debug.print("{d},{d} ", .{ doFire_x, doFire_y }); // ++
doFire_idx = doFire_y * FIRE_W + doFire_x;
//spread fire
spread_px = screen_buf[doFire_idx] ;// BOOM
then: N: x = 0, y = 0 #new screen - first screen
0,0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 0,10 0,11 0,12 0,13 0,14 0,15 0,16 0,17 0,18 0,19 0,20 0,21 0,22 0,23 0,24 0,25 0,26 0,27 0,28 0,29 0,30 0,
31 0,32 0,33 0,34 0,35 0,36 0,37 0,38 0,39 0,40 0,41 0,42 0,43 0,44 0,45 0,46 0,47 0,48 0,49 0,50 0,51
"thread 1041596 panic: index out of bounds: index 316659348806830, len 7644" #/BOOM I can't quite imagine how x=0, y=51 gets mangled so badly. Adding additional debug statements prevents the panic, so clearly something else is overriding the pointer boundary. -j1 doesn't change things. I am wondering if OSX M* + ubuntu multipass + zig 0.13 + libc is too much...something about the build from a system pov is a mismatch. I may need to investigate a proper ubuntu build...somehow??? |
good ol' fashion printf debugging lmao Im using Linux and everything seems fine on the error handling branch. |
Folded into main....may not be perfect, but hopefully still better! |
Hello, I checked out
|
Thank you! Could you try |
Does anyone else see this build issue on Ubuntu?
The text was updated successfully, but these errors were encountered: