Calling engineFreeModel right after destroying custom content causes crash
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
- request new ID, load custom TXD/DFF/COL to that ID
- 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
- [X] I have read and understood the Security Policy and this issue is not security related.
i think the crash was fixed in #3357