p2sr / SourceAutoRecord

Speedrun plugin for Source engine games.
https://sar.portal2.sr/
MIT License
93 stars 29 forks source link

Portal 2 crash when alt-tabing #119

Open kkard2 opened 1 year ago

kkard2 commented 1 year ago

Portal 2 sometimes crashes when I have SAR loaded and try to alt-tab (I play in fullscreen mode). Cannot reliably reproduce, but already happened a few times; issue seems related to thread pool cleanup (edit: i'm dumb, this is portal's function, Engine::Frame_Hook is sar):

SAR 1.12.8-pre6 (Built 03:20:34 Nov 22 2022)
Segmentation fault caused by address 0x7b0ae911
    (+0x0) [0x7b0ae911]
    (+0x0) [0x7b0aed3d]
    (+0x0) [0x7b0b27ca]
    (+0x0) [0x79215084]
    (+0x0) [0x791ff332]
    (+0x0) [0x791ff381]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(DestroyThreadPool+0x5b07a5c0) [0x5b07a5c0]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(DestroyThreadPool+0x5b07ae9f) [0x5b07ae9f]
    (+0x0) [0x791fcf34]
    (+0x0) [0x791fea96]
    (+0x0) [0x791fd7a5]
    (+0x0) [0x79202a23]
    (+0x0) [0x78b8b169]
    (+0x0) [0x78c3688c]
    (+0x0) [0x78c38fe3]
    (+0x0) [0x78c47b1b]
    (+0x0) [0x78c47c6a]
    (+0x0) [0x78c47d04]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(F+0x78c9a15d) [0x78c9a15d]
    D:\SteamLibrary\steamapps\common\Portal 2\sar.dll(Engine::Frame_Hook+0x20606a) [0x254c606a]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(F+0x78c98f40) [0x78c98f40]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(F+0x78c9905f) [0x78c9905f]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(F+0x78c99a9e) [0x78c99a9e]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(LauncherMain+0x5b1790c0) [0x5b1790c0]
    (+0x0) [0x009311dc]
    (+0x0) [0x0093177e]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(BaseThreadInitThunk+0x76a0fef9) [0x76a0fef9]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(RtlGetAppContainerNamedObjectPath+0x77147bbe) [0x77147bbe]
    D:\SteamLibrary\steamapps\common\Portal 2\portal2.exe(RtlGetAppContainerNamedObjectPath+0x77147b8e) [0x77147b8e]

(this is the only log I've got, will update the issue if I confirm it always looks like this) edit: got a log that is almost exactly the same, only difference is addresses

ThisAMJ commented 1 year ago

From the looks of the crash report, you don't have the sar.pdb crash report expander installed (must be in uppercase Portal 2). You can find it on the 1.12.8-pre6 release page.

Crashing by tabbing out is a common issue with source games in general, so it's entirely possible that SAR is doing nothing to contribute to this.

mlugg commented 1 year ago

Nah, they do have the PDB, that's why you see the Engine::Frame_Hook call.

As AMJ says, Source games are somewhat prone to crashing when tabbing out in general, so this might not be related to SAR, but I won't rule it out. Unfortunately, the crash report is pretty unhelpful here, since it looks like the game's caught the crash and tried to gracefully unload or something and that's then crashing (this happens a lot, SAR's crash report system unfortunately often isn't all that useful).

How often does this happen? If it's a 1 in 100 kinda thing, I'm inclined to say it's just Source being bad. However, if it's particularly frequent, and verifiably less frequent without SAR, something's definitely amiss. Issues like this are pretty hard to track down - if you have the knowhow to build SAR yourself, it'd be neat if you could try and trigger the crash with a debugger attached and see if that gives any more useful info.

Unfortunately there's not much else I can do with this information atm - I run on Linux and don't have the time atm for in-depth debugging, and if this is SAR's fault it's probably something really stupid like a null ptr deref in some random feature. But do let me know if you manage to get any more information or nail down the trigger any more precisely!

kkard2 commented 1 year ago

It's 1 in 100 kinda thing, I alt+tab pretty often so source being funny may be the case. Altho I don't remember it being an issue before installing SAR...

About crashing with debugger:

  1. Crash is pretty inconsistent, so it would be hard (I could just always play with debugger attached /hj)
  2. I dread configuring any C++ project ;_;

I will think about it; also playing without SAR a bit after I figure out how often it crashes may be a good idea to exclude source being source.

kkard2 commented 1 year ago

okay, i managed to get a crash with attached debugger and this is what i've got: image image image image

altho i would assume this does not help much; do you want me to go somewhere specific when i get an exception? not really familiar with debugging native apps

mlugg commented 1 year ago

hm yeah that's not overly helpful lmao

The crash is happening in fame code, and at first glance doesn't seem like it really could be SAR's fault, but I can't rule it out (SAR can cause weird crashes sometimes, no idea why). That said, there's unfortunately not much I can do for this atm, at least without a consistent repro.

joaopinto24 commented 1 year ago

I used to have the same problem, verifying game files and switching to windowed borderless fixed it for me