[kovarex] [0.17.9] Crash drawing path preview in train GUI

This subforum contains all the issues which we already resolved.
Post Reply
Khaim
Inserter
Inserter
Posts: 31
Joined: Sun Jan 04, 2015 6:31 pm
Contact:

[kovarex] [0.17.9] Crash drawing path preview in train GUI

Post by Khaim »

What Happened
I was about to hop in a train (only one on the map so far) to go to an outpost. The following took place over 2-3 seconds.
  1. Clicked on train to open GUI.
  2. Dragged map over to the east, ~2 screens.
  3. Hovered over track and held Ctrl. Nothing happened; I expected a temporary-path line. (I might have clicked here, not sure.)
    Edit N: Further debugging shows the crash happened here. I was able to move the cursor for a few more seconds, is all.
  4. Noticed there was still a "temp stop" listed in the train schedule. This shouldn't have been there; it had been several minutes since I used the train. This stop was listed when I opened the GUI but I didn't notice/pay attention until the previous step failed.
  5. Clicked the [X] to remove the stop from the schedule.
  6. Game crashed.
Edit 1: Reloaded autosave and tried again. I was able to remove the stop, crash occurred when I Ctrl-clicked. There's a slight delay where the game freezes, I think that's why I had the wrong cause before.

The existing track at time of crash should have been a single block: a long paired line with a loop at both ends. There were no signals anywhere; I haven't placed any yet in this save. While building the track I did create some Y-junctions, and then removed them by tearing up one branch, so there are some small disconnected track pieces in a few places. My guess is that this plus the one-big-loop somehow corrupted the train-block data structure.

No mods.

Key crash lines (full log attached)
3041.879 Error CrashHandler.cpp:515: Received SIGSEGV
[... CrashHandler stuff ...]
c:\cygwin64\tmp\factorio-build-1cqbqz\src\rail\trainpathfinder.cpp (268): TrainPathFinder::constructPath
c:\cygwin64\tmp\factorio-build-1cqbqz\src\rail\trainpathfinder.cpp (54): TrainPathFinder::findPath
c:\cygwin64\tmp\factorio-build-1cqbqz\src\gui\minimapgui.cpp (226): LocomotiveMinimapWidget::prepare
c:\cygwin64\tmp\factorio-build-1cqbqz\src\gui\minimapgui.cpp (67): MinimapBase::paint
c:\cygwin64\tmp\factorio-build-1cqbqz\src\gui\minimapgui.hpp (56): MinimapWidget::paintBackgroundShadow
Attachments
_autosave3.zip
(6.47 MiB) Downloaded 78 times
factorio-current.log
(9.3 KiB) Downloaded 69 times
Last edited by Khaim on Wed Mar 13, 2019 3:17 pm, edited 2 times in total.

Khaim
Inserter
Inserter
Posts: 31
Joined: Sun Jan 04, 2015 6:31 pm
Contact:

Re: [0.17.9] Crash opening train GUI

Post by Khaim »

Reloaded a few more times, tested some things. I think my original guess was right.
  • Pressing "Ctrl" is enough to trigger the crash. Makes sense, the segfault is in the path-preview code.
  • Removing and re-building the train doesn't help.
  • The block-preview on signal placement doesn't crash, but it does show that disconnected track segments are still being counted as the same block as the main track.
I'm going to try removing all the disconnected bits and see if that fixes the problem.

Khaim
Inserter
Inserter
Posts: 31
Joined: Sun Jan 04, 2015 6:31 pm
Contact:

Re: [0.17.9] Crash opening train GUI

Post by Khaim »

More testing:
  • Drove manually from base (West) to middle. Removed tracks so disconnected segments were counted as separate blocks. This might not be relevant after all; I was misremembering how "blocks" are defined. Track pieces which aren't connected, but have overlapping bounding boxes should be in the same block, right? That appears to be the case and is working correctly.
  • Placed some signals to check blocking. Removed all signals. (This shouldn't matter, but might affect internal data structure?)
Then I think I found the bug.
  1. Drove to far East end, then went around loop to face West (on upper track of parallel-straightway).
  2. Opened train GUI.
  3. Ctrl-hovered near middle of track, top side. Green path appears, seems to update correctly.
  4. Move cursor (holding Ctrl) to bottom side of track. Game crashes.
Notes
  • Train is a single locomotive, no wagons. In particular, it is one-way.
  • Track is one giant loop, with no signals. I'm pretty sure that makes it two-way.
  • For the original crash, train was at West side facing East along the bottom track. I'm 90% sure I tried to Ctrl-hover the top track.
  • From East side, facing West along top track, the top track works (or seems to) and the bottom track crashes.
Theory
The path-preview code crashes if
(a) a single-headed train,
(b) is on a two-way piece of track, and
(c) attempts to path to a point to which the shortest legal route is backwards.
There's a possible 4th condition, (d) the train has a legal forward route. This has held for all my examples, since my track is a giant un-signaled loop, but I suspect it's not necessary.

Khaim
Inserter
Inserter
Posts: 31
Joined: Sun Jan 04, 2015 6:31 pm
Contact:

Re: [0.17.9] Crash drawing path preview in train GUI

Post by Khaim »

I built a new, smaller track loop; I could not get it to crash under any conditions. I suspect there's a size threshold involved somewhere. A few more observations from the original track:
  • Adding any signals on the track (one-way, two-way, one-way the wrong way) prevents the crash.
  • Adding a Y-junction anywhere on the track appears to prevent the crash.
  • Crossing a second track (i.e. an X-junction) shortly in front of the train anywhere causes the train's path-preview to crash immediately, regardless of where the target position is.

Khaim
Inserter
Inserter
Posts: 31
Joined: Sun Jan 04, 2015 6:31 pm
Contact:

Re: [0.17.9] Crash drawing path preview in train GUI

Post by Khaim »

I was going to throw some signals down and get on with my game... but I accidentally triggered another crash:
  1. Loaded previously-attached autosave.
  2. Clicked on train to open GUI.
  3. Noticed there was still a "temp stop" listed in the train schedule. (No other stops.)
  4. Noticed the train was in "manual" mode.
  5. Clicked toggle to "automatic" mode.
  6. Game crashed.
Attachments
factorio-current.log
(8.7 KiB) Downloaded 66 times

kovarex
Factorio Staff
Factorio Staff
Posts: 8058
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [kovarex] [0.17.9] Crash drawing path preview in train GUI

Post by kovarex »

Thanks for the report, this is the actual fix text so you know what caused it:
changelog wrote: Fixed train path finding in a special case of a loop with no signals and exactly one intersection.
Fixed for 0.17.22

Post Reply

Return to “Resolved Problems and Bugs”