I have tested and logged until I found the perfect example of the crash issue. I did the following test :
1/ Set debug logs to write information about old and new waypoints,
2/ Launch a new Adventure and wait until waypoint changes appear in Debug.log, to show the function works before saving,
3/ Save the game and exit Transcendence,
4/ Relaunch Transcendence, load the game and wait for the crash,
5/ Extract the relevant parts of the Debug.log file.
I made several test runs. Finally, the crash occured immediately after the reload. When checking the log, I saw that the event that crashed was at the very first tick. This sheer luck allowed me to identify in the first run the ship and marker that caused the crash. So I post these extracts.
First, here is the code used to output these logs. I made minor changes to the code posted in the previous post, to better log what happens. You see that this time, the games won't crash on objDestroy, but on objGetPos.
Code: Select all
; Set variables
(setq oldStatus (objGetData sourceShip "status"))
(setq newStatus "statusToWaypoint")
(setq oldWaypoint (objGetData sourceShip "waypoint"))
; Logging old waypoint
(if (eq oldWaypoint Nil)
(block Nil
(setq message " Old waypoint : Nil")
(dbglog message)
)
(block Nil
(setq message (cat " Old waypoint #" oldWaypoint))
(dbglog message)
(setq angle (sysVectorAngle (objGetPos oldWaypoint)))
(setq distance (sysVectorDistance Nil (objGetPos oldWaypoint)))
(setq message (cat " Old waypoint #" oldWaypoint " at [" angle "°;" distance "ls]"))
(dbglog message)
)
)
; Destroy older waypoint if it exists
(objDestroy oldWaypoint)
Then here's the log, which shows the following sequence of events :
- Tick 2 : 1st execution of socOnTimerSetNextWaypoint function : no marker exists, one is created,
- Tick 1100 : 2nd execution of socOnTimerSetNextWaypoint function : existing marker is destroyed, a new is created and takes the same ID that was just freed,
- Tick 2140 : OnOrderCompleted event is fired and schedules execution of socOnTimerSetNextWaypoint for the next tick,
- Game is then saved and restored; by sheer luck, this happens to occur just between these ticks 2140 and 2141,
- Tick 2141 : 3rd execution of socOnTimerSetNextWaypoint function : saved/restored marker crashes the game whenever used in a function.
We also see that both ship and marker take different IDs when saved/reloaded. From that we can infer that they are dynamically allocated pointers. The crash could then be caused by an invalid pointer going to a bad memory zone, or something like that.
Code: Select all
01/22/2009 08:32:51 --------------------------------------------------------------------------------
01/22/2009 08:32:51 Start logging session
01/22/2009 08:32:51 Transcendence 0.99c
01/22/2009 08:32:54 Loading extension: Extensions\ATA-GateGlobalsD8
01/22/2009 08:32:54 Loading extension: Extensions\ATA-StarSystemsD6
01/22/2009 08:32:54 Loading extension: Extensions\DebugCode
01/22/2009 08:32:54 Loading adventure desc: Extensions\HK-001-Adventure-SoC-045-Common-Functions
01/22/2009 08:32:54 Loading extension: Extensions\HK-101-Systems-CoreLeague-034-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-201-Stations-Common-019-Fix-Orbit
01/22/2009 08:32:54 Loading extension: Extensions\HK-202-Stations-CoreLeague-032-ZIP-006
01/22/2009 08:32:54 Loading extension: Extensions\HK-203-Stations-TMS-011-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-301-Ships-SystemWideFreighters-031-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-302-Ships-Pirates-021-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-303-Ships-InterStellarFreighters-014-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-304-Ships-PolicePatrol-016-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-401-Items-Shields-006-ZIP-006
01/22/2009 08:32:54 Loading extension: Extensions\HK-402-Items-Weapons-010-ZIP-006
01/22/2009 08:32:54 Loading extension: Extensions\HK-601-DockScreens-003-ZIP-006
01/22/2009 08:32:54 Loading extension: Extensions\HK-E01-IA-Ships-008-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-E02-IA-Systems-008-Common-Functions
01/22/2009 08:32:54 Loading extension: Extensions\HK-E03-IA-SystemWideFreighters-008-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-E04-IA-Pirates-008-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-E05-IA-InterStellarFreighters-008-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-E06-IA-PolicePatrol-013-Debug-Code
01/22/2009 08:32:54 Loading extension: Extensions\HK-E07-IA-PlayerShips-001-Common-Functions
01/22/2009 08:32:54 Loading extension: Extensions\HK-EFF-Debug-Facility-001-Debug-Code
01/22/2009 08:32:59 Loading adventure: Extensions\HK-001-Adventure-SoC-045-Common-Functions
01/22/2009 08:33:01
...
01/22/2009 08:33:02 (2) Ship Santa Cruz #221466632 : Entering socOnTimerSetNextWaypoint
01/22/2009 08:33:02 Old waypoint : Nil
01/22/2009 08:33:02 New waypoint #221503432 at [98°;1913ls]
01/22/2009 08:33:02 (2) Ship Santa Cruz #221466632 : Exiting socOnTimerSetNextWaypoint
01/22/2009 08:33:02
...
01/22/2009 08:33:26 (1100) Ship Santa Cruz #221466632 : Entering socOnTimerSetNextWaypoint
01/22/2009 08:33:26 Old waypoint #221503432
01/22/2009 08:33:26 Old waypoint #221503432 at [98°;1913ls]
01/22/2009 08:33:26 New waypoint #221503432 at [84°;2424ls]
01/22/2009 08:33:26 (1100) Ship Santa Cruz #221466632 : Exiting socOnTimerSetNextWaypoint
...
01/22/2009 08:33:59
01/22/2009 08:33:59 (2140) Ship Santa Cruz #221466632 : Entering socPolicePatrolShipsOnOrdersCompleted
01/22/2009 08:33:59 Old status : statusToWaypoint
01/22/2009 08:33:59 (2140) Ship Santa Cruz #221466632 : Exiting socPolicePatrolShipsOnOrdersCompleted
01/22/2009 08:34:03 End logging session
01/22/2009 08:35:39 --------------------------------------------------------------------------------
01/22/2009 08:35:39 Start logging session
01/22/2009 08:35:39 Transcendence 0.99c
01/22/2009 08:35:42 Loading extension: Extensions\ATA-GateGlobalsD8
01/22/2009 08:35:42 Loading extension: Extensions\ATA-StarSystemsD6
01/22/2009 08:35:42 Loading extension: Extensions\DebugCode
01/22/2009 08:35:42 Loading adventure desc: Extensions\HK-001-Adventure-SoC-045-Common-Functions
01/22/2009 08:35:42 Loading extension: Extensions\HK-101-Systems-CoreLeague-034-Debug-Code
01/22/2009 08:35:42 Loading extension: Extensions\HK-201-Stations-Common-019-Fix-Orbit
01/22/2009 08:35:42 Loading extension: Extensions\HK-202-Stations-CoreLeague-032-ZIP-006
01/22/2009 08:35:42 Loading extension: Extensions\HK-203-Stations-TMS-011-Debug-Code
01/22/2009 08:35:42 Loading extension: Extensions\HK-301-Ships-SystemWideFreighters-031-Debug-Code
01/22/2009 08:35:42 Loading extension: Extensions\HK-302-Ships-Pirates-021-Debug-Code
01/22/2009 08:35:42 Loading extension: Extensions\HK-303-Ships-InterStellarFreighters-014-Debug-Code
01/22/2009 08:35:42 Loading extension: Extensions\HK-304-Ships-PolicePatrol-016-Debug-Code
01/22/2009 08:35:42 Loading extension: Extensions\HK-401-Items-Shields-006-ZIP-006
01/22/2009 08:35:43 Loading extension: Extensions\HK-402-Items-Weapons-010-ZIP-006
01/22/2009 08:35:43 Loading extension: Extensions\HK-601-DockScreens-003-ZIP-006
01/22/2009 08:35:43 Loading extension: Extensions\HK-E01-IA-Ships-008-Debug-Code
01/22/2009 08:35:43 Loading extension: Extensions\HK-E02-IA-Systems-008-Common-Functions
01/22/2009 08:35:43 Loading extension: Extensions\HK-E03-IA-SystemWideFreighters-008-Debug-Code
01/22/2009 08:35:43 Loading extension: Extensions\HK-E04-IA-Pirates-008-Debug-Code
01/22/2009 08:35:43 Loading extension: Extensions\HK-E05-IA-InterStellarFreighters-008-Debug-Code
01/22/2009 08:35:43 Loading extension: Extensions\HK-E06-IA-PolicePatrol-013-Debug-Code
01/22/2009 08:35:43 Loading extension: Extensions\HK-E07-IA-PlayerShips-001-Common-Functions
01/22/2009 08:35:43 Loading extension: Extensions\HK-EFF-Debug-Facility-001-Debug-Code
01/22/2009 08:35:46 Loading adventure: Extensions\HK-001-Adventure-SoC-045-Common-Functions
01/22/2009 08:35:47
01/22/2009 08:35:47 (2141) Ship Santa Cruz #213081416 : Entering socOnTimerSetNextWaypoint
01/22/2009 08:35:47 Old waypoint #221503432