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.41k stars 435 forks source link

Freeing custom id of an element right after it's destroyed is causing crash #3316

Open youtastelikerottencorpse opened 8 months ago

youtastelikerottencorpse commented 8 months ago

Describe the bug

After an element with custom id is destroyed, calling engineFreeModel within the same frame of destroy is causing a crash

If custom id don't have custom dff or txd, game isn't crashing

engineFreeModel-crash

Steps to reproduce

Either:

Version

Client: v1.6-release-22388 (Windows 10, x64) Server: localhost, same

Additional context

If you are a scripter reading this and having crashes related to your custom models (or if you thinking so), to prevent the bug, put a 50ms delay to your engineFreeModel call. Can't promise it will fix :^)

Relevant log output

No response

Security Policy

TheNormalnij commented 5 months ago

This is because MTA does not actually destroy objects/vehicles/peds when we call destroyElement. destroyElement marks an element with the "being deleted" flag, puts it on the "delete on next tick" list, and removes it from the element list. engineFreeModel scans the element list and changes the affected model ID to a safe parent ID.