[Server Crash][Dump File] The thread tried to read from or write to a virtual address for which it does not have the appropriate access

Hi,

I’m having a issue with my server. It keeps crashing. I tried to update to the newest version.

So some more explaining:

  • I’ve been facing this issue for at east one full month
  • I’ve updated the server multiple times
  • Keeps crashing with the same error in the dump file: “The thread tried to read from or write to a virtual address for which it does not have the appropriate access.”
  • Crashes at different times (sometimes is lasts 2 days. Sometimes it crashes after 30min)
File downloads

2e9ae994-0fba-425f-a89b-8f98844a332e.dmp (1.3 MB, )
3f30590d-fe22-4a9c-a3ad-8b118dc10b7d.dmp (1.4 MB)
3fc2ec8f-930d-4c1a-bdd0-545ed1ab9f9a.dmp (1.4 MB)
5e9aa358-579d-4c6d-b5f1-75cb253c1d90.dmp (1.3 MB)
6cfa80e5-44ec-4d96-97cd-39571758d77a.dmp (1.3 MB)
6f3964b0-7c9e-45af-88a2-5e3f0f90f7fb.dmp (1.3 MB)
7c38a462-8680-4e53-8039-dd26aacd418d.dmp (1.3 MB)
49fdecd3-8ae6-41ee-aa92-c80f94716504.dmp (1.3 MB)
a02bdb0a-7a17-4928-a9af-ae952f338373.dmp (1.3 MB)
48dcead2-3a1b-4903-96db-0bd0815fc3a5.dmp (1.3 MB)
e7fd1917-ee6a-462a-9371-f88a18568545.dmp (1.3 MB)
e22f5f0c-ef24-4dfa-afc0-8cb4c4e98fa3.dmp (1.3 MB)
e95e3dc1-c9e4-4006-a847-b3adc244bc9a.dmp (1.3 MB)
e69299e1-435e-4f92-a43d-c6ae0afdd5ac.dmp (1.3 MB)
f0979575-053b-4734-9e09-aa2e5cbe4bdd.dmp (1.3 MB)
e6a4d148-3a4d-4067-96f3-d4f9c0f658dd.dmp (1.3 MB)

Screenshot from one of the dumps in visual studio:

What resources do you have that attempt to handle playerConnecting events? It seems one of them is calling setKickReason after the connection is already finalized.

2 Likes

Tnx for your quick reaction!

So I think the kick function is called in after a ‘if whitelist’ check.
I marked it with:

-- *****************************
-- *****************************
-- *****************************
Event handler
AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
	deferrals.defer()
	local _source = source
	deferrals.update("\nChecking Username...")
	local name = GetPlayerName(_source)
	if(string.match(name, "[*%%'=`\"]")) then
        PTCore.Functions.KickUser(_source, 'Je hebt in je naam een teken('..string.match(name, "[*%%'=`\"]")..') zitten wat niet is toegestaan.\nGelieven deze uit je steam-naam te halen.', setKickReason, deferrals)
        CancelEvent()
        return false
	end
	if(PTCore.PTShared.StringContainsWords(name:lower(), {'drop', 'table', 'database'})) then
        PTCore.Functions.KickUser(_source, 'Je hebt in je naam een woord('..PTCore.PTShared.StringContainsWords(name:lower(), {'drop', 'table', 'database'})..') zitten wat niet is toegestaan.\nGelieven deze uit je steam-naam te halen.', setKickReason, deferrals)
        CancelEvent()
        return false
	end
	deferrals.update("\nChecking Steam Id...")
    local identifiers = GetPlayerIdentifiers(_source)
    print(json.encode(identifiers))
    local steamid = PTCore.Functions.GetIdentifierFromSource(_source, "steam")
	local ip = PTCore.Functions.GetIdentifierFromSource(_source, "ip")
    if ((steamid:sub(1,6) == "steam:") == false) then
        PTCore.Functions.KickUser(_source, 'Je moet steam open hebben om op deze server te spelen.', setKickReason, deferrals)
        CancelEvent()
        return false
    end
    if ((ip:sub(1,3) == "ip:") == false) then
        PTCore.Functions.KickUser(_source, 'Je moet een ip hebben om op deze server te spelen.', setKickReason, deferrals)
        CancelEvent()
        return false
    end
	deferrals.update("\nChecking Ban Status...")
    local Banned = PTCore.Functions.IsUserBanned(_source)
    if(Banned ~= false) then
        PTCore.Functions.KickUser(_source, 'Ban reden:\n'..Banned, setKickReason, deferrals)
        CancelEvent()
        return false
    end
	deferrals.update("\nChecking VPN status...")
    if(PTCore.Functions.IsUserUsingVPN(ip) ~= false) then
        PTCore.Functions.KickUser(_source, 'Je gebruikt vermoedelijk een VPN.\nGelieven deze afsluiten ivm veiligheid.', setKickReason, deferrals)
        CancelEvent()
        return false
    end
-- *****************************
-- *****************************
-- *****************************
	deferrals.update("\nChecking Whitelist status...")
    if(PTCore.Functions.IsUserWhitelisted(_source) ~= true) then
        PTCore.Functions.KickUser(_source, 'Je bent helaas niet gewhitelist.\nVraag een whitelist aan!', setKickReason, deferrals)
        CancelEvent()
        return false
    end
	deferrals.update("\nChecking Server status...")
    if(PTCore.Functions.IsUserAllowedOnThisServer(_source) ~= true) then
        PTCore.Functions.KickUser(_source, 'Dit is de development server.\nHier ben je helaast niet op toegelaten!', setKickReason, deferrals)
        CancelEvent()
        return false
    end
	deferrals.update("\nAdding to queue...")
	PTCore.Queue.AddUser(_source, deferrals)
	-- Setup Queue Refferals
	-- deferrals.done()
end)
'kick function'

This contains a while loop to make sure the player is removed & kicked from te server
Kinda weird but it works since there was a build where it wouldn’t always kick them.

PTCore.Functions.KickUser = function(source, reden, setKickReason, deferrals) -- Kicks a user and makes sure he is kicked
	local src = source
	if (deferrals ~= nil) then
		TriggerEvent("LOGGER:SimpleEmbedHook", "deferralskicks", "Rood", GetPlayerName(src), "Player gekicked uit het pre-laadscherm "..GetPlayerName(src).."("..GetPlayerIdentifiers(src)[1]..") voor:\n"..reden.."")
	end
	reden = "\n"..reden.."\n\nKijk op onze discord voor meer informatie: <discord link removed for Forums>"
-- *****************************
-- *****************************
-- *****************************
	if(setKickReason ~=nil) then
		setKickReason(reden)
	end
	Citizen.CreateThread(function()
		if(deferrals ~= nil)then
			deferrals.update(reden)
			Citizen.Wait(2500)
		end
		DropPlayer(src, reden)
		local i = 0
		while (i <= 4) do
			i = i + 1
			while true do
				--DropPlayer(src, string.format( strings.bannedjoin, BanDb[1].naam, BanDb[1].reden, BanDb[1].door, os.date('%d/%m/%Y %H:%M:%S', BanDb[1].verlooptseconde )))
				if(GetPlayerPing(src) >= 0) then
					break
				end
				Citizen.Wait(100)
				--deferrals.update(string.format( strings.bannedjoin, BanDb[1].naam, BanDb[1].reden, BanDb[1].door, os.date('%d/%m/%Y %H:%M:%S', BanDb[1].verlooptseconde )))
				Citizen.CreateThread(function() 
					DropPlayer(src, reden)
				end)
			end
			Citizen.Wait(5000)
		end
	end)
end

Yeah, you shouldn’t use setKickReason after any sort of wait - especially not if using deferrals.

This crash will be fixed in an upcoming server update, however for now removing the setKickReason call should suffice (and replacing with deferrals.done(‘reason to kick’) or similar).

1 Like

Ahh oke. But how am I supposed to kick someone?
When I say with defferals.done(“kicked”) doesn’t that make him join the server?
Since that’s also what I call in the queue function when they can join. Or does the “defferals.done” kick someone when a string is given?
Or shuold I do something like defferals.update(“You’r not allowed to join”) and then just never come back to the defferal?

It seems to be running fine now. With using the drop player method and not using setKickReason. tnx <3
This topic can be closed :slight_smile:

Passing an argument rejects the player - passing no argument accepts the player.

1 Like

Ahh oke. Tnx

same problem, you can help me?

I have that same issue what can I do to fix it?
and please explain im a newbie plz