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 Tkinter crashes on macOS 11.1 beta #86646

Closed
kode54 mannequin opened this issue Nov 27, 2020 · 11 comments
Closed

Python Tkinter crashes on macOS 11.1 beta #86646

kode54 mannequin opened this issue Nov 27, 2020 · 11 comments
Labels
3.9 only security fixes OS-mac type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@kode54
Copy link
Mannequin

kode54 mannequin commented Nov 27, 2020

BPO 42480
Nosy @ronaldoussoren, @ned-deily, @kode54, @fxcoudert

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2020-11-29.02:01:24.587>
created_at = <Date 2020-11-27.09:13:29.216>
labels = ['OS-mac', '3.9', 'type-crash']
title = 'Python Tkinter crashes on macOS 11.1 beta'
updated_at = <Date 2020-12-21.05:10:25.568>
user = 'https://github.com/kode54'

bugs.python.org fields:

activity = <Date 2020-12-21.05:10:25.568>
actor = 'ned.deily'
assignee = 'none'
closed = True
closed_date = <Date 2020-11-29.02:01:24.587>
closer = 'ned.deily'
components = ['macOS']
creation = <Date 2020-11-27.09:13:29.216>
creator = 'kode54'
dependencies = []
files = []
hgrepos = []
issue_num = 42480
keywords = []
message_count = 11.0
messages = ['381933', '381936', '381937', '381989', '382028', '382032', '382033', '382037', '383371', '383376', '383487']
nosy_count = 4.0
nosy_names = ['ronaldoussoren', 'ned.deily', 'kode54', 'fxcoudert']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue42480'
versions = ['Python 3.9']

@kode54
Copy link
Mannequin Author

kode54 mannequin commented Nov 27, 2020

The Tkinter module, in a freshly built copy of Python 3.9 built by Brew, using the latest Xcode 12.3 command line tools, crashes on Big Sur 11.1 beta. It emits the following error:

macOS 11 or later required !

I believe I recently read on macOS developer documentation, there is a special behavior in the system version reporting now, possibly only taking effect in 11.1 and newer. Basically, if you query the major version first, you'll get 11 or higher. If you query the minor version first, it will switch on compatibility mode and start reporting either 10.15 or 10.16, I'm not terribly sure which, but it does lie and say it's running version 10.

@kode54 kode54 mannequin added topic-tkinter 3.9 only security fixes type-crash A hard crash of the interpreter, possibly with a core dump labels Nov 27, 2020
@ronaldoussoren
Copy link
Contributor

On macOS 11 the system version is reported as 11.x if the binary was build using Xcode 12, and as 10.16.x for older binaries.

@ronaldoussoren
Copy link
Contributor

Note that a python installation created using Mac/BuildScript/build-instalelr.py works fine on macOS 11.0 (I haven't tested on 11.1 beta yet). This may be a problem with homebrew or the way it builds Python and/or Tcl/Tk.

@kode54
Copy link
Mannequin Author

kode54 mannequin commented Nov 28, 2020

And I can't report it to Homebrew, either, since they refuse to acknowledge bug reports against beta versions of the OS. I guess I can bug them when 11.1 becomes a stable release, by which time I'll probably be on 11.2.

I'll file Feedback with Apple, too, as they're more likely to actually know what's going on.

@ned-deily
Copy link
Member

I've installed the 11.1 beta (of 2020-11-17) on an Intel-64 virtual machine and installed and run the test suite for the recently released 3.9.1rc1 Universal2 binaries from python.org. The tests, including tkinter tests, run similarly to how they do on 11.0.1. Further, as far as I can tell, there is no place within Python itself where such a message ("macOS 11 or later required !") is emitted; I did not search the Tcl or Tk sources since you didn't say which version is in use. Be aware that 3.9.1rc1 is the first official Python release that supports macOS 11 Big Sur so it may be that the brew version you were using has preliminary patches for Big Sur support that differ from the final versions. Depending what you are trying to do, you might want to use the python.org 3.9.1rc1 or 3.9.1 final (when released) until there is a supported brew version. Or, as Ronald suggest, you may need to track down exactly what and how the brew recipes are building for Tcl, Tk, and Python. Good luck!

@kode54
Copy link
Mannequin Author

kode54 mannequin commented Nov 29, 2020

Sorry about that. I didn't know that Big Sur support wasn't added until post-3.9.0. I'll check if Brew has a newer version now, and even if not, if I can install a Git version for testing.

Incidentally, the error is occuring inside either the Tk or Tcl frameworks, and it's not a version that Brew supplies. Like the system copies of Python 2 and 3, Brew links its builds against the system Tcl and Tk frameworks, which appear to have some bugs in the beta.

Thanks for testing, though.

@ned-deily
Copy link
Member

If Homebrew links against the Apple-supplied Tcl and Tk frameworks, which are in /System/Library/Frameworks, all bets are off as those are deprecated and hopelessly out-of-date versions of Tcl/Tk 8.5. If tkinter is linked to Tcl and Tk frameworks in /Library/Frameworks and there are Tcl and Tk frameworks there, those are not supplied by Apple; they are either installed by Homebrew from somewhere else (ActiveTcl or perhaps built from source). It can be confusing trying to determine which instance of Tcl or Tk tkinter is actually using at runtime on macOS. The command:

python3.9 -m test.pythoninfo

will display the patch level of Tk in use. There is some more detail of how it all works here: https://www.python.org/download/mac/tcltk/

@kode54
Copy link
Mannequin Author

kode54 mannequin commented Nov 29, 2020

That command also crashes with the same error. And I already verified with otool -L on the tkinter shared object file that it does indeed link the /System/Library/Frameworks version of both Tcl and Tk.

In fact, if I remember correctly, Homebrew's entire stance is to import and build as little as possible, always preferring to link to system bundled frameworks, no matter what. Maybe they'll rethink this one.

@fxcoudert
Copy link
Mannequin

fxcoudert mannequin commented Dec 19, 2020

Hi, Homebrew developer here, we're seeing this with macOS 11.1 and I think it's not a python issue but an Apple's Tcl/Tk issue. The backtrace I have is:

0 libsystem_kernel.dylib 0x00007fff2031f462 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff2034d610 pthread_kill + 263
2 libsystem_c.dylib 0x00007fff202a0720 abort + 120
3 Tcl 0x00007fff6fe1eb55 Tcl_PanicVA + 398
4 Tcl 0x00007fff6fe1ebd5 Tcl_Panic + 128
5 Tk 0x00007fff6ff1ead5 TkpInit + 385
6 Tk 0x00007fff6fe9e788 0x7fff6fe6d000 + 202632
7 _tkinter.cpython-39-darwin.so 0x0000000102d2d701 Tcl_AppInit + 84
8 _tkinter.cpython-39-darwin.so 0x0000000102d289fa _tkinter_create + 975
9 org.python.python 0x00000001027251bb cfunction_vectorcall_FASTCALL + 203
10 org.python.python 0x000000010279cff3 call_function + 403
11 org.python.python 0x000000010279a184 _PyEval_EvalFrameDefault + 27452
12 org.python.python 0x000000010279db3b _PyEval_EvalCode + 1998
13 org.python.python 0x00000001026f55d8 _PyFunction_Vectorcall + 248
14 org.python.python 0x00000001026f4e67 _PyObject_FastCallDictTstate + 212
15 org.python.python 0x00000001026f5891 _PyObject_Call_Prepend + 139
16 org.python.python 0x000000010273de96 slot_tp_init + 87
17 org.python.python 0x00000001027376f7 type_call + 150
18 org.python.python 0x00000001026f4fa3 _PyObject_MakeTpCall + 266
19 org.python.python 0x000000010279d027 call_function + 455
20 org.python.python 0x000000010279a184 _PyEval_EvalFrameDefault + 27452
21 org.python.python 0x000000010279db3b _PyEval_EvalCode + 1998
22 org.python.python 0x000000010279356d PyEval_EvalCode + 79
23 org.python.python 0x00000001027ce5b5 run_eval_code_obj + 110
24 org.python.python 0x00000001027cd9ad run_mod + 103
25 org.python.python 0x00000001027cc9dc PyRun_StringFlags + 182
26 org.python.python 0x00000001027cc8e9 PyRun_SimpleStringFlags + 69
27 org.python.python 0x00000001027e3802 Py_RunMain + 425
28 org.python.python 0x00000001027e40c1 pymain_main + 306
29 org.python.python 0x00000001027e410f Py_BytesMain + 42

This seems confirmed by the fact that I can reproduce with Apple's own python:

$ /usr/bin/python3 
Python 3.8.2 (default, Nov  4 2020, 21:23:28) 
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> root = tkinter.Tk()
macOS 11 or later required !
zsh: abort      /usr/bin/python3

I will file a bug report with Apple.

@fxcoudert
Copy link
Mannequin

fxcoudert mannequin commented Dec 19, 2020

Reported to Apple as FB8945560

@ned-deily
Copy link
Member

@fxcoudert: If you are trying to link with the Apple-provided system Tcl and Tk frameworks, don't. They have been seriously broken since macOS 10.7 and stuck at Tk 8.5.9. The only visible Apple action has been to deprecate them. Any Python on macOS that claims to support tkinter (and, hence, IDLE) *must* be able to link with, and preferably supply, newer versions of Tcl and Tk. And for use on current versions of macOS, that also means Tcl/Tk 8.6.x, not 8.5.x.

https://www.python.org/download/mac/tcltk/

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes OS-mac type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

2 participants