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

Crash when using Lua to create objects set to “display a random frame” with zero frames per view #461

Open
aaronfreed opened this issue Jan 14, 2024 · 0 comments

Comments

@aaronfreed
Copy link

aaronfreed commented Jan 14, 2024

i discovered last night that if you try to use Lua to create a scenery item with a sequence set to “display a random frame” with zero frames per view (i’m a dingus and forgot to save my shapes file), the game crashes without explanation (on Windows, Linux, and presumably Intel Macs, at least) due to a floating-point exception (i.e., division by zero). this line in map.cpp appears to be the culprit:

global_random()%animation->frames_per_view

here’s the top of a stack trace that Solra ran in Valgrind:

#0  0x0000555555624af3 in randomize_object_sequence(short, unsigned short)
    (object_index=object_index@entry=109, shape=<optimized out>)
    at map.cpp:1147
#1  0x0000555555644969 in randomize_scenery_shape(short)
    (object_index=<optimized out>, object_index@entry=109) at scenery.cpp:143
#2  0x00005555556da2b3 in Lua_Sceneries_New(lua_State*) (L=0x55555673e010)
    at lua_objects.cpp:768

i’m guessing this problem also occurs with items, ephemera, effects, and possibly monsters, though i haven’t actually confirmed this.

in any case, i plan to make a PR that makes an assertion to detect this error and present a helpful error message rather than crash without explanation, so that the next time someone has this problem, they don’t waste five hours of their life thinking faulty Lua caused the crash. not that i know anyone this has happened to. shifty-eyes-ani

(thanks to Solra for the stack trace and for identifying the line that was causing the issue.)

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

1 participant