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

Tkinter crashes with Tk-related error on macOS with ActiveTcl 8.6 #78494

Closed
taleinat opened this issue Aug 1, 2018 · 26 comments
Closed

Tkinter crashes with Tk-related error on macOS with ActiveTcl 8.6 #78494

taleinat opened this issue Aug 1, 2018 · 26 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes OS-mac topic-tkinter

Comments

@taleinat
Copy link
Contributor

taleinat commented Aug 1, 2018

BPO 34313
Nosy @terryjreedy, @ronaldoussoren, @taleinat, @ned-deily, @serhiy-storchaka

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 2019-07-31.17:52:53.780>
created_at = <Date 2018-08-01.20:49:42.088>
labels = ['OS-mac', '3.8', '3.7', 'expert-tkinter']
title = 'Tkinter crashes with Tk-related error on macOS with ActiveTcl 8.6'
updated_at = <Date 2019-07-31.17:52:53.774>
user = 'https://github.com/taleinat'

bugs.python.org fields:

activity = <Date 2019-07-31.17:52:53.774>
actor = 'ned.deily'
assignee = 'none'
closed = True
closed_date = <Date 2019-07-31.17:52:53.780>
closer = 'ned.deily'
components = ['macOS', 'Tkinter']
creation = <Date 2018-08-01.20:49:42.088>
creator = 'taleinat'
dependencies = []
files = []
hgrepos = []
issue_num = 34313
keywords = []
message_count = 26.0
messages = ['322888', '322898', '322927', '322930', '322976', '323008', '323040', '323134', '326758', '326775', '326778', '326780', '326784', '326815', '326900', '326902', '326989', '331770', '331772', '331773', '331783', '331785', '348577', '348760', '348765', '348818']
nosy_count = 8.0
nosy_names = ['terry.reedy', 'ronaldoussoren', 'taleinat', 'wordtech', 'ned.deily', 'royf', 'serhiy.storchaka', 'vtudorache']
pr_nums = []
priority = None
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue34313'
versions = ['Python 3.7', 'Python 3.8']

@taleinat
Copy link
Contributor Author

taleinat commented Aug 1, 2018

On macOS 10.13.5 (the latest available) with ActiveTcl 8.6.7 (the latest available), I'm building Python from latest master (to be 3.8.0). I'm consistently having IDLE crash almost immediately, just by opening any file for editing. The crash results in the following error:

$ root/bin/python3 -m idlelib
objc[50759]: Invalid or prematurely-freed autorelease pool 0x7fb74091f050.
[1]    50759 abort      root/bin/python3 -m idlelib

In bpo-34120, @vtudorache reported a similar issue (also on macOS).

With Python 3.7.0 from python.org, everything works fine.

Strangely, replacing ActiveTcl with version 8.5.18.0 resolves this issue.

I'm not sure whether this is specific to IDLE; I'll try to provide a minimal way to reproduce.

@terryjreedy
Copy link
Member

I presume then that you tested PR8603 without opening an editor (which is certainly possible).

10.13.6 was released in the last month.

PCBuild/build.bat -e downloads missing external dependency source code into externals/ and then compiles it into compatible .dlls. This includes doing updates as appropriate. I presume that the source and compilation flags are the same as used to make a release. AFAIK, Zach Ware is mainly responsible for the current easy-to-use, easy-to-get-right status.

For a stripped-down reporducer, you might start with the files I attached to bpo-34047.

@terryjreedy terryjreedy removed their assignment Aug 1, 2018
@vtudorache
Copy link
Mannequin

vtudorache mannequin commented Aug 2, 2018

I confirm the crashes. I've tried with personal builds of python 3.5, 3.6, 3.7, with ActiveTcl and personal builds of Tcl 8.6.x, the problem does not appear with 8.5.18, but shows itself with 8.5.19 (strange, API changes?). I'll try to investigate.

@vtudorache
Copy link
Mannequin

vtudorache mannequin commented Aug 2, 2018

The problem shows itself on macOS High Sierra in some Tk Demos, independently of Python's IDLE. So there is something completely different, to report to the Tcl/Tk community. Strangely, I didn't notice the issues on Sierra, but I have no Sierra Mac right now to check it again. Even in Tk 8.5.18 (ActiveState or self-compiled) there are issues (notably the cascade menus demo, the button menus demo, others to) in rendering some UI elements. Sometimes bad indexes are reported (sort of [lindex {A LIST} index $N] gives $N not found even when in range)...

@terryjreedy
Copy link
Member

Kevin, more tk mac issues.

@wordtech
Copy link
Mannequin

wordtech mannequin commented Aug 3, 2018

The crash reported by the OP did show up at times in recent releases of Tk 8.6.x, but a lot of work went into refactoring memory management in 8.6.8 and those problems do not seem present in the current release (8.6.7 is a year old). I'd try updating to 8.6.8 and seeing if that fixes things.

@vtudorache
Copy link
Mannequin

vtudorache mannequin commented Aug 3, 2018

I was telling only that I've seen myself the issues with some Tcl/Tk versions. As I often build Tcl/Tk on macOS, I can confirm that on 8.6.8 I didn't see issues (those were effectively present in (ActiveState or not) Tcl 8.5.18, 8.5.19, 8.6.6, 8.6.7. The only issue I had was an @autoreleasepool after several open/close of the Preferences dialog in IDLE (see the 34120 issue), related probably to a partial release of resources.

@taleinat
Copy link
Contributor Author

taleinat commented Aug 5, 2018

I can confirm the these issues do *not* occur on my macOS setup when using tcl/tk 8.6.8 built from source.

@terryjreedy
Copy link
Member

Since this was opened, I have opened files in the editor, without incident with both installed 3.7.0 and 3.7.1rc1 (64 bit). Should this still stay open? Does anyony have any problems with the current release candidates?

@taleinat
Copy link
Contributor Author

taleinat commented Oct 1, 2018

I couldn't reproduce this issue with any of the 3.7.1rc1 and 3.6.7rc1 installers from python.org on my macOS.

This certainly seems like an issue with Tcl/Tk versions before 8.6.8.

It is unfortunate that ActiveState have still not released ActiveTcl 8.6.8; the latest version is 8.6.7 which does exhibit this issue.

ISTM we should update the section of the docs about GUI programming on macOS, which suggests using the latest version of Tcl/Tk from ActiveState:
https://docs.python.org/3/using/mac.html#gui-programming-on-the-mac

@vtudorache
Copy link
Mannequin

vtudorache mannequin commented Oct 1, 2018

@taleinat

The issues appear with both Tk 8.6.[:8] and (8.5.[:18] + 8.5.[19:], just in case you update the docs. For 32/64 bit installers on macOS, the only version (built by myself or ActiveState) without crashes is 8.5.18 (on my Mac).

@vtudorache vtudorache mannequin added the 3.7 (EOL) end of life label Oct 1, 2018
@taleinat
Copy link
Contributor Author

taleinat commented Oct 1, 2018

Vlad, you previously mentioned that with Tcl/Tk 8.6.8 you also didn't see this issue. Have you tried building Tcl/Tk 8.6.8 yourself? When I did so everything worked fine.

@vtudorache
Copy link
Mannequin

vtudorache mannequin commented Oct 1, 2018

Yes, like in the Pythonic Tk 8.6.[:8] :), starting at version 8.6.8 (-dev, too) I see no crash. Tcl/Tk 8.6.8 is built by myself (the last time I checked there was no 8.6.8 built on ActiveState).
As for the old 8.5 series, only 8.5.18 works with the dual 32/64 bit Python(s).

@terryjreedy
Copy link
Member

I think that the resolution of this issue should be revision of at least the tkinter paragraph in https://docs.python.org/3/using/mac.html#gui-programming-on-the-mac, and I think at least the tkinter revision should be cherry-picked into the upcoming releases. Ned, what do you want to do?

PyObjC paragraph: move to end?

Tkinter paragraph: rewrite to something like...

The standard Python GUI toolkit is tkinter, based on the cross-platform Tk toolkit (https://www.tcl.tk). Starting with the 64-bit installer in 3.6.6 and both installers in 3.7.0, an Aqua-native version of Tk is bundled the installer. Users are urged to install the most recent bug-fix releases.

'Other' paragraphs: combine into something like ...

*wxPython* and *PyQt* are other cross-platform GUI toolkits that runs natively on Mac OS X. See https://www.wxpython.org or https://riverbankcomputing.com/software/pyqt/intro.

[Does the other Qt wrapping, PySide, run natively on Mac?]

@vtudorache
Copy link
Mannequin

vtudorache mannequin commented Oct 2, 2018

@terry.reedy

Maybe "users are urged to install the most recent bug-fix releases" is a little bit misleading. As I wrote, Tcl/Tk 8.5.18 does not give crashes on macOS, when both 8.5.17 and 8.5.19 (bug-fix) do. Some times ago, if I remember well, the same thing happened 'round 8.6.3 something (there was a "bug-fix" release worse than the previous one). Should python.org installers provide only tested self-contained Tcl/Tk builds?

@terryjreedy
Copy link
Member

Current Mac installers do contain hopefully tested tcl/tk installers. (This has always been true for the Windows installers.) We are not responsible if users use anything else with Python.

@ned-deily
Copy link
Member

If I understand correctly, this is not a release blocker issue. The most up-to-date documentation for which Tcl/Tk to use on macOS has been and remains:

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

The entire https://docs.python.org/3/using/mac.html section remains woefully out-of-date; there are other open issues regarding it.

@terryjreedy terryjreedy changed the title IDLE crashes with Tk-related error on macOS with ActiveTcl 8.6 Tkinter crashes with Tk-related error on macOS with ActiveTcl 8.6 Dec 12, 2018
@terryjreedy
Copy link
Member

I installed 64-bit 3.7.2rc1 on my Macbook, with 8.6.9, and so far IDLE itself runs fine. (Other than new blackout issue reported in bpo-34313.) I will let someone else test 32/64 bit release, which Ned says also uses 8.6.9.

Vlad says in msg323040 "on 8.6.8 I didn't see issues" and in msg326778 "The issues appear with ... Tk 8.6.[:8]". Different 'issues'?

In any case, tcl/tk on the every changing macOS graphics seems 'tempermental'.

Let me revise, extend, and reword what I said earlier about 'recent releases'. I think the goal of the python x.y.z Mac equivalent of PCbuild should be to make it just as easy to build python with the current 'official' x.y.z version of tcl/tk as PCbuild does. Does the ActiveState licensing allow this? Then we could consider saying that we only support tkinter x.y.z with that tcl/tk, and IDLE patches could be tested against the expected tcl/tk they will be installed with. (This is routine on Windows. If someone breaks IDLE on Windows by replacing the installed tcl/tk, it is basically their problem.)

To put it another way, I want tcl/tk to shield me from differences between OS versions. To do that on Mac, we have to use a fairly up-to-date version of the efforts of Kevin and company.

@taleinat
Copy link
Contributor Author

Vlad says in msg323040 "on 8.6.8 I didn't see issues" and in msg326778 "The issues appear with ... Tk 8.6.[:8]". Different 'issues'?

Nope, same issues: Vlad was saying that 8.6.x versions of Tcl/Tk *before* 8.6.8 displayed these issues, but 8.6.8 is fine.

To state this point as directly as possible: Tcl/Tk 8.5.18 and 8.6.8 are fine in this regard, and apparently so is 8.6.9. The issues discussed here occur with Tcl/Tk versions 8.6.x before 8.6.8, as well as 8.5.x other than 8.5.18.

macOS users do occasionally install another version of Tcl/Tk, and IDLE will automatically use the system installed Tcl/Tk in many cases.

ISTM we should update the docs to recommend the working versions of Tcl/Tk, and warn about versions known to be problematic.

@terryjreedy
Copy link
Member

I get it now. [:8] meant .0 to .7 inclusive, like range(8).

I understand that until last spring, the tcl/tk/tkinter situation on Mac was a bit like the old American wild west. But then Ned more or less tamed it for 3.7 and now 3.6. We no longer install Python to work with system tcl and, I believe, releases compiled against 8.6 would not work with them.

Can you suggest a doc change?

tkinter has a hard-coded requirement for at least 8.4, IDLE for 8.5 (so ttk works). For future IDLE, that should be at least 8.5.18 or maybe later. I have thought about adding a startup warning if something older that the expected (tested-against) version is used, but that should be once only, requiring a 'hidden' configuration value. So maybe not worth the effort.

@taleinat
Copy link
Contributor Author

We already have a warning about Tk versions on macOS, see macosx.tkVersionWarning(). It is currently printed in new shell windows. It would be straightforward to add warnings when using anything other than 8.5.18 or 8.6.8+. I suggest this approach.

As for the docs, IMO we should update the "GUI Programming on the Mac" section of https://docs.python.org/3/using/mac.html; I'll prepare a PR.

I also suggest updating https://www.python.org/download/mac/tcltk/. The following two current paragraphs should be improved:

"If you are using Python (prior to 3.7) from a python.org 64-bit/32-bit Python installer for macOS 10.6 and later, you should only use IDLE or tkinter with an updated third-party Tcl/Tk 8.5 (not 8.6), like ActiveTcl 8.5 installed."

"If you are using macOS 10.7 or later, the Apple-supplied Tcl/Tk 8.5 still has serious bugs that can cause application crashes. If you wish to use IDLE or Tkinter, install and use a newer version of Python and of Tcl/Tk."

I'm happy to suggest clearer wording; I'm not sure where to post a patch/PR, though.

@vtudorache
Copy link
Mannequin

vtudorache mannequin commented Dec 14, 2018

The only versions of Tk not showing issues on my Mac are:

  • 8.5.18 with any Python in 3.5, 3.6, 3.7 on Mojave AND previous versions;
  • 8.6.8 when built on a 10.13 SDK, with the same Python versions.

For 8.6.8 built on Mojave SDK, there's the black background console window issue and for 8.6.9.1 the IDLE's problem showing a little black window.
I've seen no crashes yet with 8.5.18, 8.6.8, 8.6.9 (on my Mac).

@royf
Copy link
Mannequin

royf mannequin commented Jul 28, 2019

I started having a similar issue after updating to macOS Mojave 10.14.6.

I'm not using idle, but the following minimal code has a similar issue:

import tkinter as tk

w = tk.Tk()
w.mainloop()

The crash happens on mainloop.

This worked for me on macOS <= 10.14.5, but started crashing after updating to macOS 10.14.6. I'm using miniconda with conda=4.7.10, python=3.7.3, and tk=8.6.8.

The above code does work fine on the macOS 10.14.6 in a conda environment with python=3.6.2 and tk=8.5.18. But I really want to use python 3.7, which requires tk>=8.6.8, at least on the default conda channels.

@ned-deily
Copy link
Member

@royf, Without more information, we can only speculate what kind of crash you are seeing. But based on past experience, it is almost certainly a crash in Tk itself and, if so, you need to work with your supplier of Tk, presumably the conda project, to get a working version of Tk 8.6.x. Our most recent experience with building Tk on macOS for the python.org installers found that using the released Tk 8.6.8 source tarball (ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk8.6.8-src.tar.gz) was the least problematic at the moment.

@terryjreedy
Copy link
Member

Is this issue open for some specific action in a repository covered by this tracker, or should it be closed?

@ned-deily
Copy link
Member

Good question. I don't think there's anything more to do here other than to continue to monitor and evaluate future Tk releases, which we do anyway. Improvements to the build documentation etc are covered by other open issues.

@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.7 (EOL) end of life 3.8 only security fixes OS-mac topic-tkinter
Projects
None yet
Development

No branches or pull requests

3 participants