Page 1 of 1

[boskid] [2.0.19] Crash with order_deconstruction (possible index out of bounds)

Posted: Sat Nov 16, 2024 3:00 pm
by Yodo
Steps to reproduce:
1. Load the attached mod file and then load the attached game.
2. Mark one or both of the "Linked Fast underground belt" in the middle of the screen for deconstruction (make sure instant deconstruct is off) (if alt-mode is on they should be linked by a white line)

What happens:
Bots come to deconstruct the Linked Fast underground belts (expected), and when they arrive the game crashes (unexpected).

Does it always happen?
With the steps above, it happend every time I tried it; 4/4 times.


I think this is because of

Code: Select all

lbn.order_deconstruction(lbn.force, event.player_index, 1)
on line 103 of the control.lua of the mod, as if you remove the third argument the steps above do not cause a crash. Also, when trying to replicate the crash in a new wave I got an index-out-of-bounds error instead of a crash.

I also attached the log and dump files.

I thought an index of 1 would be allowed, as the docs say "An index of 1 adds the action to the latest undo action on the stack."

Re: [2.0.19] Crash with order_deconstruction (possible index out of bounds)

Posted: Mon Nov 18, 2024 1:39 am
by boskid
Thanks for the report. Issue is now fixed for 2.0.20.

Its a trivial implementation mistake on the LuaEntity side where the code simply tries to dereference nullptr when using LuaEntity::order_deconstruction when second parameter (player_index) is given as `nil` but third parameter is specified.