You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice the recursive call to callback_dtor. When the callbacks list grows large, it can end up causing a stack overflow crash.
Expected result
Don't cause a stack overflow independent of the callbacks list size
Reproduction steps
One possible way to trigger this crash from a resource is with ADD_STATE_BAG_CHANGE_HANDLER. Adding lots of handlers and reloading the resource, causes the crash when the underlying StateBagComponent::OnStateBagChange event deletes its callbacks.
fori=1,40000doAddStateBagChangeHandler(nil, nil, function(bagName, key, value, _unused, replicated)
print('state bag changed' ..bagName..'' ..key..'' ..value)
end)
end
Unsure if there are other easy ways to trigger it. In theory, anything that adds fwEvent callbacks dynamically could eventually crash.
Importancy
Crash
Area(s)
FiveM, RedM, FXServer
Specific version(s)
Any
Additional information
Got a crash dump from a user. In this case, it crashed when reloading resources and the stack has like 30K stack frames of the callback destructor, so somehow some event ended up with 30K callbacks. Possibly the stage bag change handlers, but I don't know what his resources are doing exactly.
What happened?
The callback struct forms a linked list with pointers to the next callback:
fivem/code/client/shared/EventCore.h
Lines 254 to 266 in 5529812
Its destructor gets compiled to something like this:
Notice the recursive call to
callback_dtor
. When the callbacks list grows large, it can end up causing a stack overflow crash.Expected result
Don't cause a stack overflow independent of the callbacks list size
Reproduction steps
One possible way to trigger this crash from a resource is with
ADD_STATE_BAG_CHANGE_HANDLER
. Adding lots of handlers and reloading the resource, causes the crash when the underlyingStateBagComponent::OnStateBagChange
event deletes its callbacks.Unsure if there are other easy ways to trigger it. In theory, anything that adds fwEvent callbacks dynamically could eventually crash.
Importancy
Crash
Area(s)
FiveM, RedM, FXServer
Specific version(s)
Any
Additional information
Got a crash dump from a user. In this case, it crashed when reloading resources and the stack has like 30K stack frames of the callback destructor, so somehow some event ended up with 30K callbacks. Possibly the stage bag change handlers, but I don't know what his resources are doing exactly.
CfxCrashDump_2024_06_07_14_03_59.zip
The text was updated successfully, but these errors were encountered: