citizenfx/fivem

script error in native 000000008f57a89d: arg[1]: buffer too small (8 < 24) (GetCamMatrix)

ImBaphomettt opened this issue ยท 23 comments

What happened?

It seems that since the latest update, the native function GetCamMatrix is experiencing some issues. Could this be due to improper usage on my part following recent changes, or is it simply an external issue? It was working perfectly fine just yesterday.

image

Here is code to reproduce the issue.

    local cam = CreateCam('DEFAULT_SCRIPTED_CAMERA')
    SetCamCoord(cam, GetEntityCoords(PlayerPedId()))
    SetCamActive(cam, true)
    RenderScriptCams(true, false)
    local rightVector, forwardVector, upVector, position = GetCamMatrix(cam)
    print(rightVector, forwardVector, upVector, position)

Expected result

Native working again.

Reproduction steps

  1. Execute the code client-side and get exeception

Importancy

Crash

Area(s)

FiveM

Specific version(s)

3258 (canary)

Additional information

No response

It seems that the following native is also broken: GetShapeTestResult.
image

d22tny commented
function Inventory:getVehicleInDirection(coordFrom, coordTo)
	local rayHandle = StartExpensiveSynchronousShapeTestLosProbe(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, PlayerPedId(), 0)
	local _, _, _, _, vehicle = GetShapeTestResult(rayHandle)

	return vehicle
end

-->
image

function FPTOffroad:getNearestRoadDistance()
    local coords = GetEntityCoords(PlayerPedId())
    local ret, srcNode, targetNode, laneCountForward, laneCountBackward, width = GetClosestRoad(coords.x, coords.y, coords.z, 1.0, 0, true)
    local dist1 = #(srcNode - coords)
    local dist2 = #(targetNode - coords)
    return math.min(dist1, dist2)
end

-->
image

Also GetModelDimensions also errors out:

image

So this seems to be happening on natives that return more than 1 thing.

I think @iridium-cfx could assist in this issue.

Hey, I believe iridium and the cfx are aware and working on a fix !
This issue seems to happen when the native's raw definition contains a Vector3* (so most natives returning a vector3 value)

a temporary fix change branch in your fivem client

Yeah, don't go to canary if you're not testing new features ! Tho I hope they fix this issue ASAP as we all know that many simple players are on the canary release channel !

I'm currently unable to reproduce the issue locally, running on the latest canary.

Does this still happen if you just run the command on a vanilla server?

d22tny commented

@iridium-cfx I'll do the tests right now using the GetClosestRoad native and i'll report back.

d22tny commented

@iridium-cfx You're right. It doens't happen right away.
Vanilla -> Returns as expected.
All scripts on -> Returns as expected until i spawn a car through my garage, i'll debug further to see what from the spawning function breaks it.

Most likely one of these :
GetCamMatrix
GetShapeTestResult
GetModelDimensions
GetEntityMatrix
GetClosestFirePos
GetSafeCoordForPed

I had the same error pop up on the latest build, beta seems fine. Not sure if its related but i've also had the issue pop up where GetAspectRatio(false) appears to return a vector on the latest build but not beta/release

Hmm that's weird I don't see it returning any vector here
image

I have exactly the same issue
image

Getting this issue with following code from ps-inventory:
local dimensionMin, dimensionMax = GetModelDimensions(GetEntityModel(vehicle))

image

Vehicle variable declared through a QBCore function:
local vehicle = QBCore.Functions.GetClosestVehicle()

function QBCore.Functions.GetClosestVehicle(coords)
    local ped = PlayerPedId()
    local vehicles = GetGamePool('CVehicle')
    local closestDistance = -1
    local closestVehicle = -1
    if coords then
        coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
    else
        coords = GetEntityCoords(ped)
    end
    for i = 1, #vehicles, 1 do
        local vehicleCoords = GetEntityCoords(vehicles[i])
        local distance = #(vehicleCoords - coords)

        if closestDistance == -1 or closestDistance > distance then
            closestVehicle = vehicles[i]
            closestDistance = distance
        end
    end
    return closestVehicle, closestDistance
end

Ah, I've figured out what the issue is, will hopefully push a fix soon ๐Ÿ˜…

d22tny commented

Glad to hear that, i didn't manage to error it on a vanilla server whatsoever :))

Ah, I've figured out what the issue is, will hopefully push a fix soon ๐Ÿ˜…

Perfect! I'll let you close the issue when all is well then ! โค๏ธ

The fix is merged, let me know if you are still having issues. If not, I'll close the issue tomorrow

i'm sorry sir, but still the same ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ
image

The fix is merged, let me know if you are still having issues. If not, I'll close the issue tomorrow

This is not related at all ???

image
and we have faced this debug with all scripts before this print in queue, probably it's 2 in 1

What are you even saying at this point... I can't understand you but the issue on your screenshot was fixed recently, please restart your game to make sure that you're under the correct version and tell us if it happens again

the same sir Couldn't load resource sessionmanager: Failed to open packfile: ReadBulk of header failed:

Again, this is not related to this issue so please join the discord to get support on this issue