Page 1 of 1

Error in lua seemingly coming from inside API

Posted: Sun Jul 03, 2022 8:50 pm
by BicycleEater
I've received a rather mysterious bug report for True-Nukes, including what looks like an error inside a call to the API:

The mod True Nukes (0.2.10) caused a non-recoverable error.
Please report this error to the mod author.
Error while running event True-Nukes::on_script_trigger_effect (ID 153) Flush failed: Invalid argument stack traceback: [C]:
in function 'destroy' True-Nukes/control.lua:1520:
in function 'optimisedChunkLoadHandler' True-Nukes/control.lua:1876:
in function 'atomic_weapon_hit' True-Nukes/control.lua:2093:
in function <True-Nukes/control.lua:2039>

I've asked for more details, but I wanted to ask here to see if anyone has seen this before (I ran a search first, but maybe I missed something). My guess is that it ran out of memory or something like that. The original post is here:
https://github.com/More-Wrong/Factorio- ... s/issues/5
I didn't want to post it as a bug report yet, as it's very possible that it's my own mistake, but I will if nobody knows.

Re: Error in lua seemingly coming from inside API

Posted: Sun Jul 03, 2022 10:42 pm
by BicycleEater
OK, to confirm, this was an out of memory - not a bug at all.
I guess a related feature request would be to make this more obvious (i.e. include it in the message given on screen)?

Re: Error in lua seemingly coming from inside API

Posted: Mon Jul 04, 2022 12:17 am
by Rseding91
That error comes from a failed call to

Code: Select all

fflush()
https://m.cplusplus.com/reference/cstdio/fflush/ not specific to out-of-memory. If Factorio detects an actual out-of-memory runtime it will abort the entire process and show the 'factorio crashed' dialog since we have no way to recover from an out-of-memory while a game is running.

Re: Error in lua seemingly coming from inside API

Posted: Mon Jul 04, 2022 4:41 pm
by BicycleEater
I was just thinking noting it specifically as an internal error might make it more clear - at the minute the most descriptive part is "Invalid argument stack traceback" which kinda sounds like I gave a really bad argument to the api somehow, and that crashed everything.
I'm sure it is meaningful internally, but "Internal error: Invalid argument stack traceback" would be much clearer.
It all turns out to be fairly clear looking at the logs, but the message on screen could provide more info.

Re: Error in lua seemingly coming from inside API

Posted: Mon Jul 04, 2022 6:23 pm
by Rseding91
Unfortunately the error isn't from a specific case where we detect "ah we are out of memory; show this error" it's just a generic error message that's thrown when this specific call (fflush) fails. fflush can fail for many different reasons and in different situations; all revolving around writing to files. That error got propagated back to Lua at some point and then Lua had its own error parsing the call stack and eventually that made it back to the main loop which showed the error it was given.

Re: Error in lua seemingly coming from inside API

Posted: Mon Jul 04, 2022 7:24 pm
by BicycleEater
Ah, that figures. Oh well, at least this forum post documents what failures like this mean a little.