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

Bugs that are actually features.
User avatar
Quezler
Fast Inserter
Fast Inserter
Posts: 201
Joined: Fri Mar 25, 2016 6:37 pm
Contact:

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

Post 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.
Attachments
factorio-current.log
(6.78 KiB) Downloaded 12 times
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3930
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

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

Post 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.
User avatar
Quezler
Fast Inserter
Fast Inserter
Posts: 201
Joined: Fri Mar 25, 2016 6:37 pm
Contact:

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

Post by Quezler »

Can't it crash to the menu instead of violently exiting the entire application?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3930
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

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

Post 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.
computeraddict
Filter Inserter
Filter Inserter
Posts: 341
Joined: Sat Oct 07, 2023 6:44 am
Contact:

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

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

Return to “Not a bug”