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

Freeze when using DisplayServer.clipboard_get_image with invalid data on Linux #83949

Closed
qarmin opened this issue Oct 25, 2023 · 3 comments · Fixed by #83970
Closed

Freeze when using DisplayServer.clipboard_get_image with invalid data on Linux #83949

qarmin opened this issue Oct 25, 2023 · 3 comments · Fixed by #83970

Comments

@qarmin
Copy link
Contributor

qarmin commented Oct 25, 2023

Godot version

v4.2.beta.custom_build. e8d57af

System information

Ubuntu 22.04 CI

Issue description

	var temp_variable_f2417 = "5555"
	DisplayServer.clipboard_set(temp_variable_f2417)
	DisplayServer.clipboard_get_image()

cause freeze here

#0  0x00007ffff7d1027f in __GI___poll (fds=fds@entry=0x7fffffffa4d8, nfds=nfds@entry=1, timeout=timeout@entry=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007ffff23fe86a in poll (__timeout=-1, __nfds=1, __fds=0x7fffffffa4d8) at /usr/include/x86_64-linux-gnu/bits/poll2.h:39
#2  _xcb_conn_wait (c=c@entry=0xbe05b80, vector=vector@entry=0x0, count=count@entry=0x0, cond=<optimized out>) at ../../src/xcb_conn.c:508
#3  0x00007ffff240028c in _xcb_conn_wait (count=0x0, vector=0x0, cond=0xbe05bc0, c=0xbe05b80) at ../../src/xcb_conn.c:474
#4  xcb_wait_for_event (c=0xbe05b80) at ../../src/xcb_in.c:703
#5  0x00007ffff245ffe8 in _XReadEvents () from /lib/x86_64-linux-gnu/libX11.so.6
#6  0x00007ffff2446d09 in XIfEvent () from /lib/x86_64-linux-gnu/libX11.so.6
#7  0x00000000029b45fb in DisplayServerX11::_clipboard_get_image_target (this=0xbde4b30, p_source=464, x11_window=90177540)
    at platform/linuxbsd/x11/display_server_x11.cpp:686
#8  0x00000000029b4d31 in DisplayServerX11::clipboard_get_image (this=0xbde4b30) at platform/linuxbsd/x11/display_server_x11.cpp:779
#9  0x0000000005e7d191 in call_with_validated_variant_args_retc_helper<__UnexistingClass, Ref<Image>>(__UnexistingClass*, Ref<Image> (__UnexistingClass::*)() const, Variant const**, Variant*, IndexSequence<>) (p_instance=0xbde4b30, p_method=&virtual table offset 864, p_args=0x7fffffffac00, r_ret=0x7fffffffabe8)
    at ./core/variant/binder_common.h:379
#10 0x0000000005e7bd49 in call_with_validated_object_instance_args_retc<__UnexistingClass, Ref<Image>>(__UnexistingClass*, Ref<Image> (__UnexistingClass::*)() const, Variant const**, Variant*) (base=0xbde4b30, p_method=&virtual table offset 864, p_args=0x7fffffffac00, r_ret=0x7fffffffabe8)
    at ./core/variant/binder_common.h:666
#11 0x0000000005e7afd1 in MethodBindTRC<Ref<Image>>::validated_call(Object*, Variant const**, Variant*) const (this=0xba65ee0, p_object=0xbde4b30, 
    p_args=0x7fffffffac00, r_ret=0x7fffffffabe8) at ./core/object/method_bind.h:592
#12 0x000000000341ba9e in GDScriptFunction::call (this=0xe8ae870, p_instance=0xe66ebf0, p_args=0x7fffffffcf38, p_argcount=1, r_err=..., p_state=0x0)
    at modules/gdscript/gdscript_vm.cpp:1953
#13 0x00000000032d5466 in GDScriptInstance::callp (this=0xe66ebf0, p_method=..., p_args=0x7fffffffcf38, p_argcount=1, r_error=...)
    at modules/gdscript/gdscript.cpp:1896
#14 0x000000000539e4c0 in Node::_gdvirtual__process_call<false> (this=0xe832a90, arg1=0.14999999999999997) at scene/main/node.h:318
#15 0x000000000537ee32 in Node::_notification (this=0xe832a90, p_notification=17) at scene/main/node.cpp:57
#16 0x0000000002f4155a in Node::_notificationv (this=0xe832a90, p_notification=17, p_reversed=false) at scene/main/node.h:49
#17 0x00000000075f3b06 in Object::notification (this=0xe832a90, p_notification=17, p_reversed=false) at core/object/object.cpp:836
#18 0x00000000053c7c09 in SceneTree::_process_group (this=0xe5c2b60, p_group=0xe5c2db8, p_physics=false) at scene/main/scene_tree.cpp:951
#19 0x00000000053c8147 in SceneTree::_process (this=0xe5c2b60, p_physics=false) at scene/main/scene_tree.cpp:1028
#20 0x00000000053c5f16 in SceneTree::process (this=0xe5c2b60, p_time=0.14999999999999997) at scene/main/scene_tree.cpp:508
#21 0x0000000002a321e1 in Main::iteration () at main/main.cpp:3613
#22 0x00000000029a01ec in OS_LinuxBSD::run (this=0x7fffffffd360) at platform/linuxbsd/os_linuxbsd.cpp:933
#23 0x0000000002998365 in main (argc=2, argv=0x7fffffffd928) at platform/linuxbsd/godot_linuxbsd.cpp:74

Steps to reproduce

Above

Minimal reproduction project

Above

@akien-mga
Copy link
Member

CC @Setadokalo

@Biokastin
Copy link
Contributor

clipboard_get_image calls _clipboard_get_image_target in which print_lines don't run after line 686 of display_server_x11.cpp. Something relating to the XIFEvent call seemingly.

print results
Notice the "Hello world" print_line prints while the "Goodbye world" print_line that comes after the XIFEvent call doesn't. This is the results while calling the supplied code above in a _ready function.

@Setadokalo
Copy link
Contributor

Looking into it, it looks like the problem lies somewhere in requesting clipboard data from our own window not working. The text clipboard request methods work around this by special-casing our window and returning the data directly, so I'll do something similar here. I'm not sure if this is a bug in our selection handling logic or expected behavior with X11, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants