Page 1 of 1

[Rseding91] __gc metamethod crashes the game on error

Posted: Tue Feb 20, 2018 2:59 am
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. :)

Re: __gc metamethod crashes the game on error

Posted: Tue Feb 20, 2018 7:12 am
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.

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

Posted: Tue Feb 20, 2018 9:16 am
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.

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

Posted: Tue Feb 20, 2018 5:30 pm
by Rseding91
I decided for now I'm going to just say "using __gc in a mod is unsupported".