Error in lua seemingly coming from inside API

Place for things which are bugs but we have no idea how to solve them. Things related to hardware, libraries, strange setups, etc.
Post Reply
BicycleEater
Fast Inserter
Fast Inserter
Posts: 153
Joined: Sun Jul 26, 2020 4:05 pm
Contact:

Error in lua seemingly coming from inside API

Post 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.

BicycleEater
Fast Inserter
Fast Inserter
Posts: 153
Joined: Sun Jul 26, 2020 4:05 pm
Contact:

Re: Error in lua seemingly coming from inside API

Post 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)?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13213
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Error in lua seemingly coming from inside API

Post 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.
If you want to get ahold of me I'm almost always on Discord.

BicycleEater
Fast Inserter
Fast Inserter
Posts: 153
Joined: Sun Jul 26, 2020 4:05 pm
Contact:

Re: Error in lua seemingly coming from inside API

Post 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13213
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Error in lua seemingly coming from inside API

Post 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.
If you want to get ahold of me I'm almost always on Discord.

BicycleEater
Fast Inserter
Fast Inserter
Posts: 153
Joined: Sun Jul 26, 2020 4:05 pm
Contact:

Re: Error in lua seemingly coming from inside API

Post by BicycleEater »

Ah, that figures. Oh well, at least this forum post documents what failures like this mean a little.

Post Reply

Return to “1 / 0 magic”