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

[ fix-crash-caused-by-zig-build ] - Fixed 'Illegal instruction' crash on 'rtextures' and 'raudio' model that caused by zig build. #3682

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

wisonye
Copy link
Contributor

@wisonye wisonye commented Dec 27, 2023

A quick fix for 3674.

  • When a zig raylib program links to zig-out/lib/libraylib.a and tries to call ImageResize, it crashes with the following error:

    INFO: IMAGE: Data loaded successfully (848x836 | R8G8B8A8 | 1 mipmaps)
    Illegal instruction at address 0x506653
    src/external/stb_image_resize2.h:6806:5: 0x506653 in stbir__alloc_internal_mem_and_build_samplers (/home/wison/zig/raylib-box2d-tutorials/raylib/src/rtextures.c)
    src/external/stb_image_resize2.h:7603:14: 0x483415 in stbir__perform_build (/home/wison/zig/raylib-box2d-tutorials/raylib/src/rtextures.c)
    src/external/stb_image_resize2.h:7639:12: 0x482184 in stbir_build_samplers_with_splits (/home/wison/zig/raylib-box2d-tutorials/raylib/src/rtextures.c)
    src/external/stb_image_resize2.h:7649:10: 0x4835c9 in stbir_build_samplers (/home/wison/zig/raylib-box2d-tutorials/raylib/src/rtextures.c)
    src/external/stb_image_resize2.h:7666:11: 0x483840 in stbir_resize_extended (/home/wison/zig/raylib-box2d-tutorials/raylib/src/rtextures.c)
    src/external/stb_image_resize2.h:7775:9: 0x4866e9 in stbir_resize_uint8_linear (/home/wison/zig/raylib-box2d-tutorials/raylib/src/rtextures.c)
    src/rtextures.c:1628:53: 0x4a3c4f in ImageResize (/home/wison/zig/raylib-box2d-tutorials/raylib/src/rtextures.c)
    /home/wison/zig/raylib-box2d-tutorials/src/temp_test.zig:74:19: 0x27b295 in main (temp-test)
        rl.ImageResize(
                    ^
    /home/wison/my-shell/zig-nightly/lib/std/start.zig:585:37: 0x27ba1b in main (temp-test)
                const result = root.main() catch |err| {
                                        ^
    ???:?:?: 0x7fa9a0274ccf in ??? (libc.so.6)
    Unwind information for `libc.so.6:0x7fa9a0274ccf` was not available, trace may be incomplete
  • When a zig raylib program links to zig-out/lib/libraylib.a and tries to call LoadSound, it crashes with the following error:

    NFO: AUDIO: Device initialized successfully
    INFO:     > Backend:       miniaudio / PulseAudio
    INFO:     > Format:        32-bit IEEE Floating Point -> 16-bit Signed Integer
    INFO:     > Channels:      2 -> 2
    INFO:     > Sample rate:   48000 -> 48000
    INFO:     > Periods size:  3600
    INFO: FILEIO: [resources/enable_fireball.wav] File loaded successfully
    INFO: WAVE: Data loaded successfully (48000 Hz, 16 bit, 2 channels)
    Illegal instruction at address 0x6fc636
    src/external/miniaudio.h:54131:82: 0x6fc636 in ma_data_converter_init_preallocated (/home/wison/zig/raylib-box2d-tutorials/raylib/src/raudio.c)
    src/external/miniaudio.h:54242:14: 0x6fe619 in ma_data_converter_init (/home/wison/zig/raylib-box2d-tutorials/raylib/src/raudio.c)
    src/external/miniaudio.h:56061:14: 0x704fd5 in ma_convert_frames_ex (/home/wison/zig/raylib-box2d-tutorials/raylib/src/raudio.c)
    src/external/miniaudio.h:56049:12: 0x704f71 in ma_convert_frames (/home/wison/zig/raylib-box2d-tutorials/raylib/src/raudio.c)
    src/raudio.c:911:43: 0x7b599f in LoadSoundFromWave (/home/wison/zig/raylib-box2d-tutorials/raylib/src/raudio.c)
    src/raudio.c:884:19: 0x7b5796 in LoadSound (/home/wison/zig/raylib-box2d-tutorials/raylib/src/raudio.c)
    /home/wison/zig/raylib-box2d-tutorials/src/temp_test.zig:41:38: 0x2a3ff6 in main (temp-test)
        const sound_effect = rl.LoadSound("resources/enable_fireball.wav");
                                        ^
    /home/wison/my-shell/zig-nightly/lib/std/start.zig:585:37: 0x2a480b in main (temp-test)
                const result = root.main() catch |err| {
                                        ^
    ???:?:?: 0x7fe8c9a77ccf in ??? (libc.so.6)
    Unwind information for `libc.so.6:0x7fe8c9a77ccf` was not available, trace may be incomplete

… on 'rtextures' and 'raudio' model that caused by zig build.
@raysan5 raysan5 merged commit 1727ddb into raysan5:master Dec 28, 2023
@raysan5
Copy link
Owner

raysan5 commented Dec 28, 2023

@wisonye thanks for the review. Actually, the reason for those issues should probably be investigated instead of readdressing the build mechanism...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants