[0.17.74] Game crash when exiting /editor

This subforum contains all the issues which we already resolved.
User avatar
SimonFlapse
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Feb 28, 2019 1:20 pm
Contact:

[0.17.74] Game crash when exiting /editor

Post by SimonFlapse »

My game has crashed mulitple times while leaving the scenario editor using the /editor command

It seems to have something to do with a mismatch in positions: I can often provoke this crash by trying to walk while the /editor command is restoring my character in a game with less than 60 updates per seconds

Code: Select all

100.748 Error Player.cpp:1040: Controller position and given position don't match: {-0.0195312500, 0.0000000000} != {-5.2304687500, 3.6015625000}.
It is especially annoying since I keep loosing my custom lua snippets in the lua tab of the editor every time.
Attachments
factorio-dump-current.dmp
(1.01 MiB) Downloaded 199 times
factorio-current.log
(8.31 KiB) Downloaded 206 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 14318
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by Rseding91 »

Thanks for the report. Do you have some reliable way to reproduce the crash? I notice in the log file what ever save you were using had custom control.lua scripting which might contribute to the issue.

Walking while leaving the editor should have zero impact since leaving the editor is done all at once and walking happens after it finishes.
If you want to get ahold of me I'm almost always on Discord.
User avatar
SimonFlapse
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Feb 28, 2019 1:20 pm
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by SimonFlapse »

I don't have a reliable way of reproducing it at the moment.

However I believe its happening because I'm entering /editor while my controller isn't a character and when I'm exiting /editor (and the game resumes) the custom scripting creates a character for my player and changes the controller type to character.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5281
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by Klonan »

SimonFlapse wrote: Sun Oct 27, 2019 2:03 pm I don't have a reliable way of reproducing it at the moment.

However I believe its happening because I'm entering /editor while my controller isn't a character and when I'm exiting /editor (and the game resumes) the custom scripting creates a character for my player and changes the controller type to character.
Can you attach the script or save game with the script?
User avatar
SimonFlapse
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Feb 28, 2019 1:20 pm
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by SimonFlapse »

I've attached a save that produces the crash. I haven't had time to reproduce it in a freeplay scenario

The code that I suspect is part of the crash is located in map_gen/maps/space-race/scenario.lua function at line 210.

This function gets called 600 ticks after the condition at line 425 is satisfied (Checking if the map have changed)

The character is destroyed in the script located in map_gen/maps/space-race/lobby.lua in the function at line 132 (Which is triggered by the on_player_created event)

To reproduce using the attached save:
- Press the 'Join Union of Factory Employees' button
- Enter /editor as soon as possible after being teleported to another surface
- Using the editor mode fly west until you reach a market (x = -403, y = 0)
- Wait for the custom map generation to change the map (It should add some ores and some out-of-map tiles) (Stay in editor mode)
- use /editor to exit editor mode
- Move around and toggle /editor mode until crash

The custom script's logic, in broad terms:

on_player_created, destroy character and set the players controller to ghost
After some time, some condition is satisfied, triggering:
a function that creates a character entity for the player and sets the controller type to character

I hope this helps, although it contains a heavy scenario
Attachments
factorio-dump-previous.dmp
a dump produced from the attached save
(1.03 MiB) Downloaded 190 times
factorio-previous.log
A crash log produced from the attached save
(7.17 KiB) Downloaded 210 times
0.17.74_Crash.zip
(13.82 MiB) Downloaded 196 times
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5281
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by Klonan »

Thats a big hefty script,

Can you try narrowing it down to just 1 script file for me?
Or just the 1 script event handler that cans reproduce the issue?
User avatar
SimonFlapse
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Feb 28, 2019 1:20 pm
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by SimonFlapse »

I've given it a quick shot, to narrow it down to a single file (That depends on some other custom scripts)

The script is located in map_gen/maps/default.lua

I hope this is enough.

Code: Select all

local Event = require 'utils.event'
local Token = require 'utils.token'
local Task = require 'utils.task'

local delayed_restore_character = Token.register(function() -- A way of storing the function to prevent desyncs (The function restores the character)
    for i = 1, #game.players do
        local player = game.players[i]
        local character = player.character
        if character then
            character.destroy()
        end
        player.set_controller {type = defines.controllers.god}
        player.create_character()
    end
end)

local function on_player_created(event)
    local player = game.get_player(event.player_index)

    local character = player.character
    if character and character.valid then
        player.character.destroy()
    end
    player.set_controller {type = defines.controllers.ghost}
    Task.set_timeout_in_ticks(600, delayed_restore_character, {}) -- Delays restoring the character by 600 ticks
end

Event.add(defines.events.on_player_created, on_player_created) -- Registers the on_player_created function as a callback when the on_player_created_event is triggered
Edit: I have uploaded a new log and dump so that it doesn't contain irrelevant information
Attachments
factorio-dump-current.dmp
(1.03 MiB) Downloaded 193 times
factorio-current.log
(7.51 KiB) Downloaded 208 times
0.17.74_Minimal_Crash.zip
(14.05 MiB) Downloaded 193 times
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5281
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by Klonan »

I can't seem to get it to crash,

What are the exact steps I need to make in order to reproduce the error (with the minimal save game)
User avatar
SimonFlapse
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Feb 28, 2019 1:20 pm
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by SimonFlapse »

Steps:
Restart the save
repeat:
{
Type /editor
Move around
}

Oversized GIF showing the steps: https://drive.google.com/open?id=1Q4QqO ... LmGm5FFvIL
MP4 file: https://drive.google.com/open?id=1ltU-5 ... 3Xmq888Oi4
Rseding91
Factorio Staff
Factorio Staff
Posts: 14318
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.74] Game crash when exiting /editor

Post by Rseding91 »

Thanks for the reproduction steps. It's now fixed for the next version of 0.17.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”