[Rseding91] __gc metamethod crashes the game on error

Things that we don't consider worth fixing at this moment.
emptyrivers
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Feb 20, 2018 2:42 am

[Rseding91] __gc metamethod crashes the game on error

Post by emptyrivers »

Stack trace: https://pastebin.com/vMh8X7mt To reproduce (this works with any object which errors during finalization, this is just the shortest command I could think of):

Code: Select all

/c setmetatable({}, {__gc = error})
I realize that a crash due to writing a bad finalizer routine is technically my fault, but it would be nice if the game told me exactly where I went wrong, instead of panicking all the way to the desktop. :)
Rseding91
Factorio Staff
Factorio Staff
Posts: 14601
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: __gc metamethod crashes the game on error

Post by Rseding91 »

I'm not even sure if mods using the __gc meta-method is deterministic...

I don't think it is. And I can't think of a use-case for mods needing it so I'm going to disable it for mod-use.
If you want to get ahold of me I'm almost always on Discord.
emptyrivers
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Feb 20, 2018 2:42 am

Re: [Rseding91] __gc metamethod crashes the game on error

Post by emptyrivers »

Fair enough, I suppose, and I can work around its absence.

In case you're curious, the reason I came across this is that I'm experimenting with building a layer on top of the gui element API, and I had wanted to be able to release the names of destroyed elements to be used again. Since element.destroy() immediately (from the perspective of the modder) renders all children invalid it would have been simplest to just allow the garbage collector to clean up the bits I created. Ideally, then the garbage collector would finalize my stuff and let me release the names. I can restructure to side-step the issue, so the absence of __gc is nbd.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14601
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] __gc metamethod crashes the game on error

Post by Rseding91 »

I decided for now I'm going to just say "using __gc in a mod is unsupported".
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Won't fix.”