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

[Python] Using tkinter dead-locks the interpreter #6967

Open
OscarL opened this issue May 29, 2022 · 1 comment
Open

[Python] Using tkinter dead-locks the interpreter #6967

OscarL opened this issue May 29, 2022 · 1 comment
Labels

Comments

@OscarL
Copy link
Contributor

OscarL commented May 29, 2022

Today I finally was able to try to use the tkinter-enabled python packages that @Begasus worked on for closing #6914 (thanks again!).

Unfortunately it seems to freeze (dead-lock ?) at the most fundamental step (creating the tkinter.Tk() "root window").

Example hello_world_tkinter.py:

import tkinter

root = tkinter.Tk()
label = tkinter.Label(root, text ="Hello World")
label.pack()
root.mainloop()

you can even comment out the last three lines, because it deadlocks on root = tkinter.Tk().

Just in case the problem was not in Python or on its tkinter module, but on its tcl/tk dependencies, I tried running some tcl and tk programs directly (using wish).

They seem to work fairly well. From simple "hello world" programs, to more complex examples (fully funtional SpiroGraphs!).

Using the debugger on the deadlocked Python interpreter yields the following output (shortened to what seems relevant):

Debug information for team /boot/system/bin/python3.10 (4722):
CPU(s): 2x AMD Athlon II
Memory: 7.94 GiB total, 1.00 GiB used
Haiku revision: hrev55181+66 Apr  2 2022 06:49: (x86_64)

Active Threads:
	thread 4740: team 4722 debug task 
	thread 4722: python3.10 (main)
		state: Debugged

		Frame		IP			Function Name
		-----------------------------------------------
		00000000	0x1a58429b82	_kern_mutex_switch_lock + 0xa 
			Disassembly:
				_kern_mutex_switch_lock:
				0x0000001a58429b78:           4989ca  mov %rcx, %r10
				0x0000001a58429b7b:   48c7c009000000  mov $0x9, %rax
				0x0000001a58429b82:             0f05  syscall  <--

		0x7fa9b2bb01b0	0x1a5843ab47	cond_wait(_pthread_cond*, _pthread_mutex*, long) + 0x87 
		0x7fa9b2bb01d0	0x1a5843ac13	pthread_cond_wait + 0x13 
		0x7fa9b2bb0220	0x17a6bf95b90	SdlTkXOpenDisplay + 0x3a0 
		0x7fa9b2bb0250	0x17a6bf6b97d	TkpOpenDisplay + 0xd 
		0x7fa9b2bb02c0	0x17a6bed2813	CreateTopLevelWindow + 0x2b3 
		0x7fa9b2bb0320	0x17a6bed2aa8	TkCreateMainWindow + 0x48 
		0x7fa9b2bb03d0	0x17a6beddbe4	CreateFrame.part.0 + 0x584 
		0x7fa9b2bb0440	0x17a6bede463	TkCreateFrame + 0xa3 
		0x7fa9b2bb0710	0x17a6bed4158	Initialize + 0x4c8 
		0x7fa9b2bb0740	0xe436b0ed9c	Tcl_AppInit + 0x74 
		0x7fa9b2bb07a0	0xe436b07b0a	Tkapp_New + 0x4a1 
		0x7fa9b2bb07f0	0xe436b0d42f	_tkinter_create_impl + 0x140 
		0x7fa9b2bb08a0	0xe436b0e512	_tkinter_create + 0x4dd 
		0x7fa9b2bb08f0	0x1d34e6cf4d2	cfunction_vectorcall_FASTCALL + 0xab 
		0x7fa9b2bb0950	0x1d34e77b326	_PyObject_VectorcallTstate + 0x7b 
		0x7fa9b2bb0990	0x1d34e77b383	PyObject_Vectorcall + 0x3b 
		0x7fa9b2bb0a10	0x1d34e78c46c	call_function + 0xff 
		0x7fa9b2bb1b40	0x1d34e787d92	_PyEval_EvalFrameDefault + 0xa161 
		0x7fa9b2bb1b70	0x1d34e77b593	_PyEval_EvalFrame + 0x33 
		0x7fa9b2bb1bc0	0x1d34e78a8bf	_PyEval_Vector + 0x97 
		0x7fa9b2bb1c10	0x1d34e67dc91	_PyFunction_Vectorcall + 0x74 
		0x7fa9b2bb1c80	0x1d34e67d682	_PyObject_FastCallDictTstate + 0x93 
		0x7fa9b2bb1d00	0x1d34e67deff	_PyObject_Call_Prepend + 0xba 
		0x7fa9b2bb1d50	0x1d34e6f95af	slot_tp_init + 0x6d 
		0x7fa9b2bb1da0	0x1d34e6ea68a	type_call + 0x193 
		0x7fa9b2bb1e00	0x1d34e67d8bf	_PyObject_MakeTpCall + 0x15b 
		0x7fa9b2bb1e60	0x1d34e77b308	_PyObject_VectorcallTstate + 0x5d 
		0x7fa9b2bb1ea0	0x1d34e77b383	PyObject_Vectorcall + 0x3b 
		0x7fa9b2bb1f20	0x1d34e78c46c	call_function + 0xff 
		0x7fa9b2bb3050	0x1d34e787ee5	_PyEval_EvalFrameDefault + 0xa2b4 
		0x7fa9b2bb3080	0x1d34e77b593	_PyEval_EvalFrame + 0x33 
		0x7fa9b2bb30d0	0x1d34e78a8bf	_PyEval_Vector + 0x97 
		0x7fa9b2bb3150	0x1d34e77da0e	PyEval_EvalCode + 0xb9 
		0x7fa9b2bb3190	0x1d34e7df7a5	run_eval_code_obj + 0x93 
		0x7fa9b2bb31f0	0x1d34e7df88e	run_mod + 0xab 
		0x7fa9b2bb3250	0x1d34e7df595	pyrun_file + 0xaa 
		0x7fa9b2bb32d0	0x1d34e7ddd3a	_PyRun_SimpleFileObject + 0x279 
		0x7fa9b2bb3310	0x1d34e7dd288	_PyRun_AnyFileObject + 0xa9 
		0x7fa9b2bb33f0	0x1d34e80583c	pymain_run_file_obj + 0x1d9 
		0x7fa9b2bb3430	0x1d34e8058e6	pymain_run_file + 0x92 
		0x7fa9b2bb3480	0x1d34e805f05	pymain_run_python + 0x1ab 
		0x7fa9b2bb34a0	0x1d34e805ff0	Py_RunMain + 0x16 
		0x7fa9b2bb34e0	0x1d34e80606d	pymain_main + 0x49 
		0x7fa9b2bb3520	0x1d34e8060e7	Py_BytesMain + 0x36 
		0x7fa9b2bb3540	0x100ede64630	main + 0x1b 
		0x7fa9b2bb3570	0x100ede64609	_start + 0x39 
		0x7fa9b2bb35a0	0x99488ac593	runtime_loader + 0x103 
		00000000	0x7ffe0bb72260	commpage_thread_exit + 0 

Same happens on both Python 3.7.12-3 and Python 3.10.2-3. Haiku beta3 x86-64 (but also on recent nightlies).

I wish I could do more than just bug reports, but... I'm not skilled enogh.

@Begasus
Copy link
Contributor

Begasus commented Jun 10, 2022

Can confirm the dead-lock (tested on 32bit nightly), don't know how to solve it though :/

OscarL added a commit to OscarL/haikuports that referenced this issue Jun 7, 2023
* Remove some clutter.
* Provide non-suffixed "cmd:"s for default Python version.
* Drop unnecessary gcc BUILD_PREQUIRES, and switch recipe to "any".
* Add missing typing_extensions dependency.

All "cmd:" now work at least with "--version" parameter, except for
`tkconch`, that deadlocks (known issue for Python + Tk: haikuports#6967).
Begasus pushed a commit that referenced this issue Jun 9, 2023
* Remove some clutter.
* Provide non-suffixed "cmd:"s for default Python version.
* Drop unnecessary gcc BUILD_PREQUIRES, and switch recipe to "any".
* Add missing typing_extensions dependency.

All "cmd:" now work at least with "--version" parameter, except for
`tkconch`, that deadlocks (known issue for Python + Tk: #6967).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants