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

Runtime Errors: "Alignment Fault" and "Memory Access Out of Bounds" #9

Open
slashpot opened this issue Sep 22, 2024 · 5 comments
Open

Comments

@slashpot
Copy link

Hi,

I tried to compile this project but encountered the following runtime error:

Uncaught RuntimeError: Aborted(alignment fault)
    at abort (websockets-doom.js:663:41)
    at alignfault (websockets-doom.js:343:3)
    at imports.<computed> (websockets-doom.js:9675:20)
    at websockets-doom.wasm (websockets-doom.wasm:0x5ad94a)
    at websockets-doom.wasm.SaveGameSettings (d_net.c:137:31)
    at websockets-doom.wasm.D_CheckNetGame (d_net.c:238:5)
    at websockets-doom.wasm.D_DoomMain (d_main.c:1648:5)
    at websockets-doom.wasm.main (i_main.c:68:5)
    at ret.<computed> (websockets-doom.js:9701:20)
    at websockets-doom.js:695:12

I found that this error is caused by the emscripten flag SAFE_HEAP=1. After setting this flag to 0, the game reaches the menu screen. However, when starting a level, the game freezes with the following runtime error:

websockets-doom.js:54 Uncaught RuntimeError: memory access out of bounds
    at websockets-doom.wasm.P_PlayerThink (p_user.c:267:40)
    at websockets-doom.wasm.P_Ticker (p_tick.c:145:6)
    at websockets-doom.wasm.G_Ticker (g_game.c:870:9)
    at websockets-doom.wasm.RunTic (d_net.c:88:5)
    at websockets-doom.wasm.TryRunTics (d_loop.c:696:13)
    at websockets-doom.wasm.D_RunFrame (d_main.c:395:5)
    at websockets-doom.wasm.dynCall_v (websockets-doom.wasm:0x4fe465)
    at ret.<computed> (websockets-doom.js:9439:24)
    at websockets-doom.js:647:12
    at browserIterationFunc (websockets-doom.js:8607:41)

I tried the following flags, but the issue persists:

-s STACK_SIZE=64mb -s INITIAL_HEAP=64mb -s DEFAULT_PTHREAD_STACK_SIZE=64mb -s INITIAL_MEMORY=256MB

I've tested on my Mac M1, x86_64 Linux, and the Gitpod workspace for this repo (https://github.com/gitpod-io/doom), all resulting in the same error. I'm running out of ideas — can anyone help check this?

@tonysamaritano
Copy link

I have the same issue. @slashpot have you found a solution?

@slashpot
Copy link
Author

slashpot commented Nov 7, 2024

unfortunately not yet.

@Code1110
Copy link

I also have the same issue. I was able to compile this fork: https://github.com/cardano-scaling/doom-wasm but it has no support for music (only sound effects). There is also a discussion about it here: chocolate-doom/chocolate-doom#538 (comment) but I have not tried yet.

@slashpot
Copy link
Author

I also have the same issue. I was able to compile this fork: https://github.com/cardano-scaling/doom-wasm but it has no support for music (only sound effects). There is also a discussion about it here: chocolate-doom/chocolate-doom#538 (comment) but I have not tried yet.

Thanks @Code1110, will definitely check it out!

@aaalloc
Copy link

aaalloc commented Dec 4, 2024

When compiling with latest emsdk, you got so many warnings ... I've tried to use the version that they used at the past (blog post posted on 2021), so I picked 2.0.20 version for emcc, tried to compile and all those annoying warnings disappeared (still one tho) and it worked !

So I guess the problem is that emcc flags isn't properly passed anymore during compilation with latest version.

edit: warning messages have nothing to do with this, it appears emscripten had some regression or changes somewhere on versions 3.1.62 and upper, so if you want to make things work install a version below than 3.1.62.

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

No branches or pull requests

4 participants