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.4k stars 431 forks source link

Calling engineFreeModel right after destroying custom content causes crash #3383

Open ffsPLASMA opened 5 months ago

ffsPLASMA commented 5 months ago

Describe the bug

When calling engineFreeModel right after destroying custom loaded content associated with that ID causes following crash:

Version = 1.6-release-22388.0.000 Time = Thu May 9 19:24:39 2024 Module = C:\Program Files (x86)\MTA San Andreas 1.6\mods\deathmatch\client.dll Code = 0xC0000005 Offset = 0x0002C089

EAX=00000000 EBX=330CE040 ECX=00000000 EDX=000066CC ESI=4DAB0268 EDI=5946E5A0 EBP=0177F930 ESP=0177F914 EIP=58A2C089 FLG=00210246 CS=0023 DS=002B SS=002B ES=002B FS=0053 GS=002B

Steps to reproduce

  1. request new ID, load custom TXD/DFF/COL to that ID
  2. destroy the custom content elements, then call engineFreeModel

Example:

-- destory TXD/DFF/COL elements for _, uCustomContent in pairs(tblContentCache) do if(isElement(uCustomContent)) then destroyElement(uCustomContent); end end

-- free ID for _, iNewEngineID in pairs(tblModelNameToAllocatedID) do engineFreeModel(iNewEngineID); end

Version

Client: 1.6-release-22388.0.000

Additional context

There is a workarround I figured out. Simply putting a small timer between these two actions solves the crash.

-- destory TXD/DFF/COL elements for _, uCustomContent in pairs(tblContentCache) do if(isElement(uCustomContent)) then destroyElement(uCustomContent); end end

-- small delay to fix crash setTimer(function() -- free ID for _, iNewEngineID in pairs(tblModelNameToAllocatedID) do engineFreeModel(iNewEngineID); end end, 10, 1);

Relevant log output

No response

Security Policy

TheNormalnij commented 4 months ago

i think the crash was fixed in #3357