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.37k stars 423 forks source link

Crash on join server #983

Closed qaisjp closed 5 years ago

qaisjp commented 5 years ago

Describe the bug

When you join a server, your game crashes.

Exception thrown at 0x013B79A8 in gta_sa.exe: 0xC0000005: Access violation writing location 0x00000001. occurred

Stack trace Currently have 2be4ee44e462c7ef82e243ce5f38305335c7c585 checked out.
client_d.dll!_malloc_base(unsigned int size) Line 29
    at d:\th\minkernel\crts\ucrt\src\appcrt\heap\malloc_base.cpp(29)
[External Code]
client_d.dll!InitClient() Line 21
    at e:\documents\mtasa-blue\client\mods\deathmatch\client.cpp(21)
core_d.dll!CModManager::Load(const char * szName, const char * szArguments) Line 149
    at e:\documents\mtasa-blue\client\core\cmodmanager.cpp(149)
core_d.dll!CConnectManager::StaticProcessPacket(unsigned char ucPacketID, NetBitStreamInterface & BitStream) Line 400
    at e:\documents\mtasa-blue\client\core\cconnectmanager.cpp(400)
[External Code]
core_d.dll!CModManager::DoPulsePostFrame() Line 276
    at e:\documents\mtasa-blue\client\core\cmodmanager.cpp(276)
core_d.dll!CCore::DoPostFramePulse() Line 1245
    at e:\documents\mtasa-blue\client\core\ccore.cpp(1245)
core_d.dll!CDirect3DEvents9::OnPresent(IDirect3DDevice9 * pDevice) Line 136
    at e:\documents\mtasa-blue\client\core\dxhook\cdirect3devents9.cpp(136)
core_d.dll!CProxyDirect3DDevice9::Present(const tagRECT * pSourceRect, const tagRECT * pDestRect, HWND__ * hDestWindowOverride, const _RGNDATA * pDirtyRegion) Line 342
    at e:\documents\mtasa-blue\client\core\dxhook\cproxydirect3ddevice9.cpp(342)
[External Code]

To reproduce

  1. Open regedit
  2. Navigate to Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
  3. Create an entry with type REG_SZ, key E:\Program Files (x86)\Rockstar Games\GTA San Andreas\gta_sa.exe (or your SA path), and value $ IgnoreFreeLibrary<client.dll>
  4. You do not need to log out and log back in.

In practice, Microsoft might be adding client.dll (or any other module) to the registry due to excessive crashes.

Or create crash.reg with the following contents:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"E:\\Program Files (x86)\\Rockstar Games\\GTA San Andreas\\gta_sa.exe"="$ IgnoreFreeLibrary<client_d.dll>"

Change client_d.dll to client.dll if you are testing against a Release build.

Screenshots

image

Version

This will crash any version of MTA.

Additional context

In the past this actually said libcef.dll. I do not know if browsers were not working for me.

This has also had a value of $ IgnoreFreeLibrary<libcef.dll>. CEF worked fine though.

Pinpointed by @sbx320

[...] I know about that loading issue As I was affected by it a long time ago And there was a very simple fix for it

basically windows has some sort of blacklist in the registry for broken dlls once your dll is there, windows ignores loadlibrary calls to it

this causes MTA to crash, as e.g. client.dll is just not being loaded

I triggered it once by causing mta to crash too often once I deleted that registry entry it worked fine again

that was years ago sadly ~2014 or 2015 I think

Useful link found by @Jusonex: IgnoreFreeLibrary registry entry causes application crash - Developer Community

Note that the link contains this snippet:

The entry only causes a problem whenever a library is loaded first using LoadLibraryEx with DONT_RESOLVE_DLL_REFERENCES and then later loaded fully. Is there a better way to load a library for validation before allowing it to execute and potentially crash the application if a dependency is missing?

This might explain why CEF works fine.

client_1.5.6-release-18560.0.000_client_00281eca_5_EPxMb_B49E175E_55F3_002_6F6E4_20190609_0039.dmp.gz

qaisjp commented 5 years ago

Added .reg file contents as well in main comment