Page 1 of 1

[2.0.49] hard crash to desktop when creating & raising entity in entity created events

Posted: Wed May 14, 2025 11:50 am
by Quezler
Ran into this whilst developing my space debris mod (tried to spawn extra asteroids when there was excessive trash), boiled it down to just this code example:

Code: Select all

script.on_event({defines.events.on_built_entity, defines.events.script_raised_built}, function(event)
  local entity = event.entity

  entity.surface.create_entity{
    name = entity.name,
    force = entity.force,
    position = entity.position,
    raise_built = true,
  }
end)
- create a new world
- ensure that code is run (through mod or /c)
- place any entity down
- instantly crash to desktop (if on mac "factorio quit unexpectedly" window should appear)

Mac crash report available through discord.

Re: [2.0.49] hard crash to desktop when creating & raising entity in entity created events

Posted: Wed May 14, 2025 11:53 am
by boskid
Thanks for the report. That is called stack overflow. Your event handler caused an event that caused another event to be raised immediately while processing previous event and this caused another event. There are no alternatives to crashing as it would otherwise violate lua api by not raising event when it was supposed to. Given it is an error caused purely by the provided script, i am classifying this as a Not a bug.

Re: [2.0.49] hard crash to desktop when creating & raising entity in entity created events

Posted: Wed May 14, 2025 11:57 am
by Quezler
Can't it crash to the menu instead of violently exiting the entire application?

Re: [2.0.49] hard crash to desktop when creating & raising entity in entity created events

Posted: Wed May 14, 2025 12:14 pm
by boskid
This crash was caused by game doing what your script asked for and it asked for more than operating system allowed so it crashed.

Re: [2.0.49] hard crash to desktop when creating & raising entity in entity created events

Posted: Wed May 14, 2025 2:53 pm
by computeraddict
Quezler wrote: Wed May 14, 2025 11:57 am Can't it crash to the menu instead of violently exiting the entire application?
Just be glad we live in the days of CTD being the default over BSoD