CyberEngineTweaks icon indicating copy to clipboard operation
CyberEngineTweaks copied to clipboard

Read Access Violation caused by Resource Reference mishandling causes crash

Open Mozz3d opened this issue 11 months ago • 1 comments

Operating system: Windows 10 Game version: 2.12a CET version: 1.32.0 GPU: GeForce RTX 3060

Description

Quoting psiberx, "when accessing res ref, cet makes a copy but doesn't increment the reference counter after passing res ref to a function, cet destroys invalid/unaccounted copies and decrements the reference counter when the counter goes to zero, the resource is freed and all res refs to the same resource are invalidated."

"CET just doesn't have a special lua wrapper to handle res refs right. It uses generic UnknownType wrapper that just copies memory." This leads to a read access violation that crashes the game when attempting to read or write to a resource multiple times, as handles are not properly destroyed.

Reproduction

Calling a method that is passed a ResourceReference multiple times will crash the game.

C++ struct TestClass { static Red::DynArrayRed::CName Test(Red::ResourceReferenceRed::anim::Rig& aResRef) { Red::HandleRed::anim::Rig rigHandle = aResRef.Get(); return rigHandle->boneNames; } } RTTI_DEFINE_CLASS(TestClass, { RTTI_METHOD(Test); });

Lua registerForEvent("onUpdate", function() player = Game.GetPlayer() deformations = ComponentParser.getComponent(player, 'deformations') --returns component by name from player ent boneNames = TestClass.Test(deformations.rig) end)

Mozz3d avatar Mar 28 '24 17:03 Mozz3d

Can confirm this here. The game crashes here and then with activated CET because of a Memory Access Violation.

Zagrthos avatar Apr 21 '24 14:04 Zagrthos

Same issue here, though the exception the game spits back out isn't clear that CET is the culprit. I can reliably reproduce it when entering Little China by vehicle, on foot, and fast traveling there. After removing CET per the wiki instructions, no more crashing. I plan to narrow this down by reinstalling CET, then bringing back my mods one by one. I'll report back soon.

I've attached some anonymized logs from my system.

stacktrace.txt report.txt metadata.9.json Cyberpunk2077.exe-20240717-235255-10540-10408.txt sysinfo.json

htmlboss avatar Jul 18 '24 02:07 htmlboss