altmp / altv-js-module-v2

alt:V JavaScript v2 module
MIT License
10 stars 9 forks source link

alt:V core exceptions crashes the game in js-v2 #204

Closed Yiin closed 8 months ago

Yiin commented 8 months ago

Running this code

new alt.LocalObject(alt.hash('ba_dlc_ba_int2_bench003'), alt.Player.local.pos, alt.Vector3.zero);

in jsv1 will result in this exception being thrown:

[Error] Error: Failed to create object

but jsv2 crashes the whole game instead.

image image

[00:52:17][Error] Failed to create local object: 00000000F1F6CFC5 is not a proper model hash
[00:52:18][Warning] System update NetworkManager took too much time to execute. 130 ms
[00:52:18] MINIDUMP: Temporary dump saved
[00:52:18] Last loaded asset: lr_cs4_02_48.ybn lr_cs4_02_35.ybn
[00:52:18] Texture info: VB_RV_SLOD3 SLOD2_Veg_02SLOD2_Veg_02_a
[00:52:18] Last deleted vehicle model 0000000000000000
[00:52:18] Last pos Point{ x: 2357.27, y: 3132.48, z: 48.2015 }
[00:52:18] Shutting down
Yiin commented 8 months ago

okay so that happens because in stacktrace code shared\src\helpers\JS.cpp:74 frame->GetScriptName() returns empty value, and if we pass empty value to *v8::String::Utf8Value the game crashes. Fixed by adding IsEmpty check before attempting Utf8Value creation.