Crashing & Timeout Issues

Hey, I have recently been looking into my server analytics and realized that there is a few crashing and timeout issues that happen pretty often. Between October and November more than half of all client crashes have been related to:
GTA5_b2545.exe!sub_1410154F8 (0xc38)
GTA5_b2545.exe!sub_140A9F8C8 (0x38)
The other ones are very rare, and are usually related to some client issue.
Throughout last month, almost 1,300 of these crashes appeared. I have absolutely no idea what causes them, but if anyone would be able to take a look it would be appreciated greatly. It seems to have some relation to players dying while lagging, as this is when big batches of the crashes happen.
Although I have only experienced the crash a couple times, some players seem to experience it very often. Here is 2 screenshots of the crashes:
unknown (1)
unknown
I could not find any results of the 0x38 crash, however here is a crash dump of 0xc38.
CfxCrashDump_2022_08_01_22_17_22.zip (1.5 MB)
d-bub told me on Discord that it is something relating to GivePedToPauseMenu, however I am not using that native in any scripts. He did tell me it can be caused by other ped natives though.

Here is my setPedModel function I use whenever I have to change a ped model:

local isProcessingModel = false
function setPedModel(model)
    DoScreenFadeIn(500)
    ShutdownLoadingScreen()
    ShutdownLoadingScreenNui()
    isProcessingModel = true
    CreateThread(function()
        local modelHash
        if type(model) == "number" then
            modelHash = model
        end
        if not modelHash then
            modelHash = GetHashKey(model)
        end
        RequestModel(modelHash)
        local timer = 0
        
        while not HasModelLoaded(modelHash) do
            timer = timer+1
            if timer > 100 then
                return
            end
            Citizen.Wait(1)
        end
        function checkCamOffset()
            local camRot = GetGameplayCamRot()
            SetPlayerModel(PlayerId(), modelHash)
            SetPedComponentVariation(PlayerPedId(), 0, 0, 0, 2)
            SetGameplayCamRelativeRotation(camRot.z, 0.0, 0.0)
            SetPlayerModel(PlayerId(), modelHash)
            SetPedComponentVariation(PlayerPedId(), 0, 0, 0, 2)
            Wait(0)
            local newCamRot = GetGameplayCamRot()
            return camRot, camRot-newCamRot
        end
        local camRot, camOffset
        if not pedModelCamOffset then
            camRot, camOffset = checkCamOffset()
            pedModelCamOffset = camOffset
        else
            camRot = GetGameplayCamRot()
            SetPlayerModel(PlayerId(), modelHash)
            SetPedComponentVariation(PlayerPedId(), 0, 0, 0, 2)
        end
        SetModelAsNoLongerNeeded(modelHash)
        SetGameplayCamRelativeRotation(camRot.z+pedModelCamOffset.z, 0.0, 0.0)
        SetGameplayCamRelativePitch(camRot.x, 1.0) -- I have to do this because the above native doesn't affect pitch when changing character models
    end)
    isProcessingModel = false
end

hello. you can try this to fix
link to an video

Hello, since I am a server owner, and this crashed has happened to over 1,300 people in the last month alone, this fix would not apply to me. I have no doubt that it is caused by an incorrect native invocation, so clearing the cache and logs would not benefit me