[0.9.3] CTD when using pointer to method of LuaObject

This subforum contains all the issues which we already resolved.
Post Reply
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

[0.9.3] CTD when using pointer to method of LuaObject

Post by drs9999 »

So I have this weird bug somewhere in my new mod that results in a crash to desktop.

Weird thing about it is that it just appears every now and then.

Steps to reproduce:
1) download the zip that includes savegame and the related wip-mod ( I also use treefarm + anti-pollution, but they should not have any influence here)
2) load the save
3) wait approx 10 seconds

4a) if a message is printed => bug did not appear, try again :D
4b) else, ctd

download:
https://www.dropbox.com/s/figv2grtuvgv01u/BR.zip

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.9.3] CTD caused by bug in modscript

Post by kovarex »

Thank you for the report, the problem is in the usage gp (pointer to method to game.player.print), we can try to fix it to not crash, or at least give better error.
Until than, I advice using game.player.print instead of gp

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: [0.9.3] CTD caused by bug in modscript

Post by drs9999 »

Interesting , I did not expect that this is the reason. Avoiding it is so easy.


So does it affect only the pointer to the print-function or function-pointer in general?

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.9.3] CTD caused by bug in modscript

Post by kovarex »

Function pointers are tricky in general. The problem is, that this was pointer to function of factorio Lua Object. The game object is persistant so the gt works, but the player object is created inside the construction game.player and removed soon later, so the pointer to the function becomes invalid.

Pointers to lua functions are possible, but can't be persistent (stored in global).

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: [0.9.3] CTD caused by bug in modscript

Post by AlexPhoenix »

kovarex, so none of the actions from Lua must not crash the game?

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.9.3] CTD caused by bug in modscript

Post by kovarex »

AlexPhoenix wrote:kovarex, so none of the actions from Lua must not crash the game?
We would like it to work that way yes :)

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.9.3] CTD caused by bug in modscript

Post by kovarex »

Ok, so we decided that we will not fix it now, as it is quite complicated issue to fix, with possible overhead, so we will put this to known issue and get back to it when people using custom scripts to crash other in multiplayer starts to be issue :)
Until then, avoid using pointers to functions of Lua objects.

Post Reply

Return to “Resolved Problems and Bugs”