multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 428 forks source link

Discord is still crashing after "No-op Discord integration" #1515

Closed Dutchman101 closed 4 years ago

Dutchman101 commented 4 years ago

Describe the bug It should be technically impossible for Discord SDK crashes to still occur on MTA builds with disabled Discord support (f6d1ffe).

But as you can see from crash stats, they still do occur: image

Clearly, something went wrong in f6d1ffe and leads to Discord not being fully unloaded, allowing instability to persist.

Dumptrace ``` EXCEPTION_RECORD: (.exr -1) ExceptionAddress: 5563e11f (DiscordHook+0x0006e11f) ExceptionCode: c0000005 (Access violation) ExceptionFlags: 00000000 NumberParameters: 2 Parameter[0]: 00000001 Parameter[1]: 00000030 Attempt to write to address 00000030 PROCESS_NAME: gta_sa.exe WRITE_ADDRESS: 00000030 ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s. EXCEPTION_CODE_STR: c0000005 EXCEPTION_PARAMETER1: 00000001 EXCEPTION_PARAMETER2: 00000030 STACK_TEXT: WARNING: Stack unwind information not available. Following frames may be wrong. 0177fa74 55642022 00000030 0177fa9b 00000001 DiscordHook+0x6e11f 0177fa9c 55611400 0177fab8 00000001 0c9692e0 DiscordHook+0x72022 0177fb0c 556146a2 00000001 0c9692e0 00000000 DiscordHook+0x41400 0177fc3c 5561b37d 0c9692e0 00000000 00000000 DiscordHook+0x446a2 0177fc74 58fec4ad 0c9692e0 00000000 00000000 DiscordHook+0x4b37d 0177fca0 599a4fd0 0c9692e0 00000000 00000000 graphics_hook32+0xc4ad 0177fd14 007f9b12 0ca21748 00000000 00000000 core!CProxyDirect3DDevice9::Present+0x80 0177fd2c 050575c8 007f99b0 00000000 007fb1c3 gta_sa+0x3f9b12 00000000 00000000 00000000 00000000 00000000 0x50575c8 ```

To reproduce No known reproduction, crash stats only.

Version r20528 (no-op Discord integration) until latest nightly r20582

Note that this particular crash offset was known before removing Discord support as well, so existing instability has simply persisted when disabling it.

Besides that, only DiscordHook.dll crashes are still there, discordgamesdk.dll crashes are gone.

Dutchman101 commented 4 years ago

Update: i noticed the above crash isn't the only one it applies to.

For comparison, DiscordHook.dll crashes before no-op: image

and here after no-op: image

There are even multiple offsets.. also, the rarer ones are included in my comparison because they should also not even have the chance to occur, no matter what.

Dutchman101 commented 4 years ago

I am closing this issue because I was wrong, this isn't an MTA problem but a bug in Discord. It's not related to our previous Discord SDK integration at all.

The crash happens because Discord exists, and Discord is running while MTA is running. Discord application's native hook (DiscordHook.dll) contains a bug which interferes with the game and crashes it.

Evidence: crash module is seen to be in Discord folders such as: C:\Users\zx\AppData\Roaming\discord\0.0.306\modules\discord_hook\e3bbef833e\DiscordHook.dll Code = 0xC0000005 Offset = 0x0006E11F EAX=00000000 EBX=C55EAB00 ECX=00000030 EDX=C55EAB01 ESI=0177FAC7 EDI=C55EABD8 EBP=0177FAA0 ESP=0177FA98 EIP=C541E11F FLG=00210246 CS=0023 DS=002B SS=002B ES=002B FS=0053 GS=002B

We found out during discussion in #development, screenshot of said part: image

It's likely that this problem in the Discord hook can crash other (DX9) games as well, we'll probably do them a favour by reporting this issue like was suggested in the above discussion. Closing this now, but at least it's documented.