dethrace-labs / dethrace

Reverse engineering the 1997 game "Carmageddon"
https://twitter.com/dethrace_labs
GNU General Public License v3.0
667 stars 38 forks source link

Game crashing at random using dethrace-e757db4-windows-x64 #396

Closed TwistedZeon closed 1 month ago

TwistedZeon commented 1 month ago

I have the GOG version of Carmageddon setup previously with the Windows 95 Restoration Pack and now I'm using dethrace on top of that. Hopefully the patch isn't affecting it but otherwise using a non audio release of dethrace didn't crash in the same setup.

I use a .bat file to launch the game setup like such

cd /d "D:\GOG Games\Carmageddon Max Pack\CARMA" procdump64.exe dethrace.exe -hires --full-screen

I do get audio so that's at least working but I seem to get random crashes that are unprompted.

I get a terminal readout like this upon crashing

D:\GOG Games\Carmageddon Max Pack\CARMA>procdump64.exe dethrace.exe -hires --full-screen Dethrace version: e757db4 Game mode: Carmageddon [WARN] S3StopMIDIOutlets stubbed [INFO] AudioBackend_Init Playback device: 'Speakers (Realtek(R) Audio)' [SDLPROCDUMP] EXCEPTION_DEBUG_EVENT [SDLPROCDUMP] ExceptionCode: 0xc0000005 (EXCEPTION_ACCESS_VIOLATION) [SDLPROCDUMP] ExceptionFlags: 0x00000000 () [SDLPROCDUMP] FirstChance: 1 [SDLPROCDUMP] ExceptionAddress: 0x39fcac0b [SDLPROCDUMP] (Non-continuable exception debug event) [SDLPROCDUMP] [SDLPROCDUMP] Writing minidump to "minidumps/dethrace_2024-07-17_16-57-42.dmp" [SDLPROCDUMP]

The exact dethrace version I'm using is from here https://github.com/dethrace-labs/dethrace/actions/runs/9962726905

I'm on Windows 11 so I'm using dethrace-e757db4-windows-x64.zip

I have uploaded a .dmp file as well https://drive.google.com/file/d/1EhuQ7XAeLv9Ux1AEVvKUjP9XKgWzd6sh/view?usp=sharing

b-kurczynski commented 1 month ago

Hello everyone,

I have found this project yesterday and I felt in love with it immediately. Kudos to @dethrace-labs for titan's work done reverse-engineering the old, good Carma.

I think I'm facing similar issue to the one reported in this ticket, although I have used dethrace-6e6ce12-windows-x64.zip

The sympthoms On my end the issue looks like audio being suddenly corrupted and starts to tick. peak and the game crashes eventually. I have observed this happens once one CDA ends and the game attempts to play next. It happens both in game and in main menu. The version of the game build from "main" but before merging "Original music" does not suffer this issue.

Double press of "S" key right before CDA comes to and end workarounds the issue.

Code analysis I did some source code analysis (without actually running it) and I found one suspicious place: https://github.com/dethrace-labs/dethrace/blob/main/src/harness/audio/miniaudio.c#L77

I have found that:

I have a memory dump. Please let me know if you would like it, then I will try to share it somehow.

dethrace-labs commented 1 month ago

Thanks very much for the analysis! That does sound suspicious and matches the behavior I saw during development where ma_sound_unint wasn’t being called at all.

I’ll take a look at the above memory dump and hopefully that might point to the same root cause. Double pressing S is a good indicator that you’ve found the cause of (at least one!) problem.

dethrace-labs commented 1 month ago

Looking at the minidump, the crash is coming from deep inside miniaudio when trying to play the next CD track. I'm going to go ahead and fix the missing call to ma_sound_uninit described by @b-kurczynski and expect/hope that to fix both issues

b-kurczynski commented 1 month ago

Hi @dethrace-labs , I just poke a bit with my local copy and I can confirm that adding missing call to ma_sound_uninit fixed my problem.