Remove empty object events to prevent segfault#2376
Conversation
|
Download the artifacts for this pull request here: GUI:
CLI: |
|
This is definitely a nice thing to have, although part of me is wondering if it should be a save error instead, somehow... I think there's a bunch of places where things can be null, e.g. due to scripts malfunctioning, and those cases may not be as simple to automatically repair when saving. Though I did recently make a 2024.13+ change which creates an empty room instance list if it happens to be null, when saving... Not too sure. If there is an error, I guess it would probably need to be obvious to fix, but not sure how often this situation comes up. |
If an element is null, then it writes 4 null bytes, which happens to be equivalent to an empty list. I think this "empty event" situation mostly occurs when a UTMT GUI user either:
Right now, this will serialize without any error or warning but lead to an immediate crash when loading the game, which is very frustrating. Most users probably forgot that they even had an empty event somewhere or didn't expect it to cause problems, so, in my opinion, this should get automatically removed, rather than letting it pass or throwing some cryptic error message. (Afaik the writer doesn't have a warning handler, so throwing a warning here is out of question anyway...) so yes, i also like explicitness instead of silent weird behavior, but in the "severe" cases you mentioned, with a malformed script output, it already throws a NRE lol |
Description
It is possible to create a new event in the UndertaleModTool GUI that has no actions.
Events with zero actions will lead to a segfault in the runner when loading chunk OBJT, because it assumes there is at least one action per event.
I encountered this bug on Undertale 1.01 Linux, maybe modern runners are not affected.
How to reproduce:
Process Chunk: OBJT 730320fish: Job 1, '~/.sg/Undertale/runner' terminated by signal SIGSEGV (Address boundary error)I added a small method to remove those empty events; fixing this bug.
Caveats
This code removes the empty events when building the data file.
If it's not desired to change anything about the UndertaleData while serializing, then this new methods needs to be called before writing.