Skip to content

Conversation

@Xenius97
Copy link
Contributor

@Xenius97 Xenius97 commented Nov 23, 2025

Fixes #4496 (maybe?)

The crash occurred because the code accessed null or invalid IPL pointers, causing an Access Violation.
Now i'm unable to reproduce crash reported in #4496 anymore with this fix. Tested with 5000 buildings without any issue.

Test code
local objects = {}
local buildings = {}
local buildingsAmount = 5000

local state = false
function createBuildings()
	local x, y, z = getElementPosition(localPlayer)
	local int, dim = getElementInterior(localPlayer), getElementDimension(localPlayer)
	for i=1,buildingsAmount do
		if i%4 == 0 then
			buildings[i] = createBuilding(1337, x, y+(i/4)+1, z+2)
			objects[i] = createObject(1337, x, y+(i/4)+1, z+3)
		elseif i%4 == 1 then
			buildings[i] = createBuilding(1337, x, y-(i/4)-1, z+2)
			objects[i] = createObject(1337, x, y+(i/4)+1, z+3)
		elseif i%4 == 2 then
			buildings[i] = createBuilding(1337, x+(i/4)+1, y, z+2)
			objects[i] = createObject(1337, x, y+(i/4)+1, z+3)
		else
			buildings[i] = createBuilding(1337, x-(i/4)-1, y, z+2)
			objects[i] = createObject(1337, x, y+(i/4)+1, z+3)
		end
		
		setElementData(buildings[i], "test", true, false)
		setElementData(buildings[i], "id", i)
		
		setElementFrozen(buildings[i], true)
		setElementDoubleSided(buildings[i], true)
		
		setElementInterior(buildings[i], int)
		setElementDimension(buildings[i], dim)
	end
	
	state = true
end

function destroyBuildings()
	for i=1,buildingsAmount do
		destroyElement(buildings[i])
		destroyElement(objects[i])
	end
	
	state = false
end

setTimer(function()
	if state then
		destroyBuildings()
	else
		createBuildings()
	end
end, 100, 0)

@Xenius97 Xenius97 closed this by deleting the head repository Nov 23, 2025
@Xenius97 Xenius97 reopened this Nov 23, 2025
@FileEX FileEX added the bugfix Solution to a bug of any kind label Nov 23, 2025
@Xenius97 Xenius97 requested a review from FileEX November 23, 2025 15:07
@FileEX FileEX merged commit 09c94ae into multitheftauto:master Nov 23, 2025
MTABot pushed a commit that referenced this pull request Nov 23, 2025
09c94ae Improve IplStoreSA validation to avoid crashes (#4572)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weird crash 0x00163482 / 0x00154918 related to buildings

2 participants