Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an OS.crash() method for testing system crash handler #55603

Merged
merged 1 commit into from
Dec 6, 2021

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Dec 3, 2021

master version of #55614.

This makes it possible to test the system's crash handler without having to modify engine code or exploit an engine bug.

This will come handy for developing features such as #55565, #33505 and godotengine/godot-proposals#1896.

Preview

extends Node


func _ready():
	OS.crash("Testing crash handler.")

Results in:

ERROR: Testing crash handler.
   at: crash (core/core_bind.cpp:211)

================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.0.dev.custom_build (ea66ea9060272d67fbf0c4264acb76a7bedfc4af)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib64/libc.so.6(+0x3d320) [0x7f3d643f0320] (??:0)
[2] core_bind::OS::crash(String const&) (/home/hugo/Documents/Git/godotengine/godot/core/core_bind.cpp:211)
[3] void call_with_ptr_args_helper<__UnexistingClass, String const&, 0ul>(__UnexistingClass*, void (__UnexistingClass::*)(String const&), void const**, IndexSequence<0ul>) (/home/hugo/Documents/Git/godotengine/godot/./core/variant/binder_common.h:244)
[4] void call_with_ptr_args<__UnexistingClass, String const&>(__UnexistingClass*, void (__UnexistingClass::*)(String const&), void const**) (/home/hugo/Documents/Git/godotengine/godot/./core/variant/binder_common.h:493)
[5] MethodBindT<String const&>::ptrcall(Object*, void const**, void*) (/home/hugo/Documents/Git/godotengine/godot/./core/object/method_bind.h:291)
[6] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) (/home/hugo/Documents/Git/godotengine/godot/modules/gdscript/gdscript_vm.cpp:1869)
[7] GDScriptInstance::call(StringName const&, Variant const**, int, Callable::CallError&) (/home/hugo/Documents/Git/godotengine/godot/modules/gdscript/gdscript.cpp:1511)
[8] Node::_gdvirtual__ready_call() (/home/hugo/Documents/Git/godotengine/godot/./scene/main/node.h:236)
[9] Node::_notification(int) (/home/hugo/Documents/Git/godotengine/godot/scene/main/node.cpp:143)
[10] Node::_notificationv(int, bool) (/home/hugo/Documents/Git/godotengine/godot/./scene/main/node.h:48)
[11] CanvasItem::_notificationv(int, bool) (/home/hugo/Documents/Git/godotengine/godot/./scene/main/canvas_item.h:?)
[12] Node2D::_notificationv(int, bool) (/home/hugo/Documents/Git/godotengine/godot/./scene/2d/node_2d.h:?)
[13] Object::notification(int, bool) (/home/hugo/Documents/Git/godotengine/godot/core/object/object.cpp:846)
[14] Node::_propagate_ready() (/home/hugo/Documents/Git/godotengine/godot/scene/main/node.cpp:188)
[15] Node::_propagate_ready() (/home/hugo/Documents/Git/godotengine/godot/scene/main/node.cpp:179)
[16] Node::_set_tree(SceneTree*) (/home/hugo/Documents/Git/godotengine/godot/scene/main/node.cpp:?)
[17] SceneTree::initialize() (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:402)
[18] OS_LinuxBSD::run() (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/os_linuxbsd.cpp:?)
[19] /home/hugo/Documents/Git/godotengine/godot/bin/godot.linuxbsd.tools.64.llvm(main+0x1c6) [0x462e7f6] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/godot_linuxbsd.cpp:58)
[20] /lib64/libc.so.6(__libc_start_main+0xd5) [0x7f3d643dab75] (??:0)
[21] /home/hugo/Documents/Git/godotengine/godot/bin/godot.linuxbsd.tools.64.llvm(_start+0x2e) [0x462e56e] (??:?)
-- END OF BACKTRACE --
================================================================

This makes it possible to test the system's crash handler without
having to modify engine code or exploit an engine bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants