You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And here is the output of running the application inside gdb
❖ gdb ./raycaster
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./raycaster...
(gdb) r
Starting program: /home/sokam/gd/other/mm/goal/e04/raycaster
This GDB supports auto-downloading debuginfo from the following URLs:
<https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n]) n
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
MinC | RayCaster
Program received signal SIGILL, Illegal instruction.
0x0000000000202c2d in rc_update (pix=0x7ffff13c0010, size=518400, clear=4294901760) at raycaster.c:154154 u8 const r = (u8)((f64)(255 * col) / (f64)(cfg_H));
(gdb) bt
#0 0x0000000000202c2d in rc_update (pix=0x7ffff13c0010, size=518400, clear=4294901760) at raycaster.c:154#1 0x0000000000203286 in main () at raycaster.c:233
Expected Behavior
The application should not crash at runtime, just like it does not crash when building with raw clang and/or gcc.
I'm guessing some of the flags set by zigcc as defaults might be causing this problem.
I've spent the entire day (+6 hours already) trying to comb through the list of flags, in hopes to find the guilty flag and disable it... but I just cannot find which one is causing the problem. I have no idea what most of them do... and there are a LOT of them...
That's all the information I could gather, but let me know if there is something else that could be useful.
The text was updated successfully, but these errors were encountered:
heysokam
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Oct 8, 2023
zig cc passes -fsanitize=undefined by default which inserts an illegal instruction in places it finds could cause UB, you can disable it with -fno-sanitize=undefined (or by fixing the UB)
raycaster.c:154:20: runtime error: 256.417 is outside the range of representable values of type'unsigned char'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior raycaster.c:154:20 in
Oh, I just saw the UB!
But this is showing when building with raw clang.
Why does the file built with zigcc not report this by default?
Extremely useful to know, ty! I didn't find that on my search.
I guess I should close this issue and go read that extensive list of comments about it.
Also, ty for the prompt reponse @xdBronch. That was really useful, since I already lost a lot of hours trying to find the invisible ghost of this problem today.
Thank you so much!
Zig Version
0.12.0-dev.798+5a4a5875d
Steps to Reproduce and Observed Behavior
Building this file: raycaster.c
Triggers what I think (and have been told in a C-lang discord server by others) is caused by UB.
Here is the result of objdump -d raycaster > raycaster.asm
The error does not happen with either of these:
But crashes at runtime with any of these:
The function that triggers the SIGILL is this one.
This is my complete
zig cc
command:Here is the output of the
zig cc -v [flags]
command listed above.And here is the output of running the application inside
gdb
Expected Behavior
The application should not crash at runtime, just like it does not crash when building with raw clang and/or gcc.
I'm guessing some of the flags set by zigcc as defaults might be causing this problem.
I've spent the entire day (+6 hours already) trying to comb through the list of flags, in hopes to find the guilty flag and disable it... but I just cannot find which one is causing the problem. I have no idea what most of them do... and there are a LOT of them...
That's all the information I could gather, but let me know if there is something else that could be useful.
The text was updated successfully, but these errors were encountered: