godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.51k stars 21.26k forks source link

Visualscript crashes the game #11637

Closed mrcdk closed 7 years ago

mrcdk commented 7 years ago

Operating system or device, Godot version, GPU Model and driver (if graphics related): Godot 3.0 master https://github.com/godotengine/godot/commit/da144fed4c49133a93b3b83cfc665352c0af351a Windows 10 x64 msvc2015

Issue description:

Using this script: https://i.imgur.com/lJGl1ZI.png Crashes the game with this backtrace:

CrashHandlerException: Program crashed
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[0] Variant::operator= (z:\cpp\godot\core\variant.cpp:2475)
[1] VisualScriptNodeInstanceFunctionCall::step (z:\cpp\godot\modules\visual_script\visual_script_func_nodes.cpp:859)
[2] VisualScriptInstance::_call_internal (z:\cpp\godot\modules\visual_script\visual_script.cpp:1596)
[3] VisualScriptInstance::call (z:\cpp\godot\modules\visual_script\visual_script.cpp:1955)
[4] ScriptInstance::call_multilevel_reversed (z:\cpp\godot\core\script_language.cpp:174)
[5] Node::_notification (z:\cpp\godot\scene\main\node.cpp:140)
[6] Node::_notificationv (z:\cpp\godot\scene\main\node.h:45)
[7] CanvasItem::_notificationv (z:\cpp\godot\scene\2d\canvas_item.h:133)
[8] Node2D::_notificationv (z:\cpp\godot\scene\2d\node_2d.h:37)
[9] PathFollow2D::_notificationv (z:\cpp\godot\scene\2d\path_2d.h:57)
[10] Object::notification (z:\cpp\godot\core\object.cpp:851)
[11] Node::_propagate_ready (z:\cpp\godot\scene\main\node.cpp:181)
[12] Node::_propagate_ready (z:\cpp\godot\scene\main\node.cpp:177)
[13] Node::_set_tree (z:\cpp\godot\scene\main\node.cpp:2540)
[14] SceneTree::init (z:\cpp\godot\scene\main\scene_tree.cpp:437)
[15] OS_Windows::run (z:\cpp\godot\platform\windows\os_windows.cpp:2255)
[16] widechar_main (z:\cpp\godot\platform\windows\godot_win.cpp:149)
[17] _main (z:\cpp\godot\platform\windows\godot_win.cpp:171)
[18] main (z:\cpp\godot\platform\windows\godot_win.cpp:183)
[19] __scrt_common_main_seh (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253)
[20] BaseThreadInitThunk
-- END OF BACKTRACE --
shit?: Invalid argument
mrcdk commented 7 years ago

I went back a couple commits that modified the file core/variant.cpp but ran out of time. This backtrace is from this commit ba4439c4914582f10b06168a50244d82efe84b20:

CrashHandlerException: Program crashed
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[0] Variant::clear (z:\cpp\godot\core\variant.cpp:1078)
[1] Variant::reference (z:\cpp\godot\core\variant.cpp:911)
[2] Variant::operator= (z:\cpp\godot\core\variant.cpp:2500)
[3] VisualScriptNodeInstanceFunctionCall::step (z:\cpp\godot\modules\visual_script\visual_script_func_nodes.cpp:859)
[4] VisualScriptInstance::_call_internal (z:\cpp\godot\modules\visual_script\visual_script.cpp:1596)
[5] VisualScriptInstance::call (z:\cpp\godot\modules\visual_script\visual_script.cpp:1955)
[6] ScriptInstance::call_multilevel_reversed (z:\cpp\godot\core\script_language.cpp:174)
[7] Node::_notification (z:\cpp\godot\scene\main\node.cpp:139)
[8] Node::_notificationv (z:\cpp\godot\scene\main\node.h:45)
[9] CanvasItem::_notificationv (z:\cpp\godot\scene\2d\canvas_item.h:133)
[10] Node2D::_notificationv (z:\cpp\godot\scene\2d\node_2d.h:37)
[11] PathFollow2D::_notificationv (z:\cpp\godot\scene\2d\path_2d.h:57)
[12] Object::notification (z:\cpp\godot\core\object.cpp:851)
[13] Node::_propagate_ready (z:\cpp\godot\scene\main\node.cpp:180)
[14] Node::_propagate_ready (z:\cpp\godot\scene\main\node.cpp:176)
[15] Node::_set_tree (z:\cpp\godot\scene\main\node.cpp:2529)
[16] SceneTree::init (z:\cpp\godot\scene\main\scene_tree.cpp:437)
[17] OS_Windows::run (z:\cpp\godot\platform\windows\os_windows.cpp:2255)
[18] widechar_main (z:\cpp\godot\platform\windows\godot_win.cpp:149)
[19] _main (z:\cpp\godot\platform\windows\godot_win.cpp:171)
[20] main (z:\cpp\godot\platform\windows\godot_win.cpp:183)
[21] __scrt_common_main_seh (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253)
[22] BaseThreadInitThunk
-- END OF BACKTRACE --
hpvb commented 7 years ago

Would it be possible to create an example project that shows just this crash for you? I'll have a look at it asap.

mrcdk commented 7 years ago

Sure:

vs_crash.zip

marcelofg55 commented 7 years ago

Could you try this patch? It didn't crash for me with this, but I'm not 100% sure its the right way to fix it vscrashfix.patch.zip

mrcdk commented 7 years ago

Yes, that patch fixes the crash @marcelofg55 but my example may be wrong. It was my first time using Visualscript and I think I should be using CallSelf nodes and not what I'm using there, like this:

https://i.imgur.com/hlDt33m.png

That actually outputs a number, I tried it following my example:

https://i.imgur.com/J1sJBW0.png

And it outputs Null

So I'm not sure if the patch is correct or not. Still a crash is a crash and should be solved.

hpvb commented 7 years ago

@marcelofg55 want to make a PR with that?

marcelofg55 commented 7 years ago

@hpvb I'm thinking that patch is not the correct way to fix this, I'm going to keep digging about it.