This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE crashes selecting Preferences menu with OS X ActiveState Tcl/Tk 8.5.12.1
Type: crash Stage: resolved
Components: IDLE, macOS Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ned.deily Nosy List: David.Pietz, Vance.Maverick, asvetlov, christian.heimes, ned.deily, pedrommeirelles, python-dev, r.david.murray, rhettinger, roger.serwy, wordtech
Priority: normal Keywords: patch

Created on 2012-09-03 00:27 by David.Pietz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
GRAB_IDLEquitUnexpectedly.tiff David.Pietz, 2012-09-03 05:02 Screenshot of complete Problem Report for IDLE
configDialog.diff wordtech, 2012-10-12 03:23
issue15853.patch ned.deily, 2012-10-19 07:35 review
patch_idle_issue_15853.sh ned.deily, 2012-12-27 02:43 Shell script to install IDLE patch for 3.3.0, 3.2.3 and 2.7.3
Messages (29)
msg169732 - (view) Author: David Pietz (David.Pietz) Date: 2012-09-03 00:27
Currently I am trying to edit idle preferences so I can edit a script which appends a log of Idle activity that I may review for study purposes.
I could not really interpret much of the crash logs in console but there seem to be two types of memory errors. I have also seen a variety of situations crash Idle and it is hampering my study as my text uses 3.x not the installed 2.x on my Macbook Pro.  As I saw an issue track mentioning os x 10.6, I upgraded to Mountain Lion, os x 10.8 but the behavior is the same. This is my first post.
msg169733 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-09-03 00:34
Can you report a specific error and a recipe to reproduce it?
msg169739 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-09-03 04:28
The crash on opening Preferences is an unresolved regression with OS X ActiveTcl 8.5.12.1, the current ActiveTcl Community Edition, that causes Tk to crash when selecting the IDLE Preferences.. command.  The regression was also in ActiveState 8.5.12 but not in 8.5.11.1.  The crash appears to be related to the Tk crash-on-copy problem documented in Issue15574.

Until the problem is resolved, if you have access to ActiveTcl 8.5.11.1 (ActiveState only makes the most recent version available to Community Edition users), you can install that.  Otherwise, you could either temporarily "deactivate" the ActiveState Tk by renaming it, for example, after quitting IDLE:

sudo mv /Library/Frameworks/Tk.framework /Library/Frameworks/Tk_disabled

This will revert to the Apple-supplied system Tk, which has some critical bugs in 10.8 Mountain Lion (it's totally unusable for IDLE in 10.6) but might be OK for your usage or, at least, for updating Preferences.

To "reactivate" ActiveTk, rename it back:

sudo mv /Library/Frameworks/Tk_disabled /Library/Frameworks/Tk.framework

Once you've made some preferences changes, it is also possible to manually edit the configuration files created in ~/.idlerc.

I will update this issue with a cross-reference to an Tcl/Tk issue when available.
msg169743 - (view) Author: David Pietz (David.Pietz) Date: 2012-09-03 05:02
r.david.murray- Thank You for your inquiry.
My recipe for this crash is (1) simply to start IDLE 3.2.3 in either Snow Leopard or Mountain Lion (2) click on the Bold "IDLE" menu in the menu bar and (3) click on menu item "preferences". At this point a dialog called "Problem Report for IDLE" appears with gobs of technical data details below a message "IDLE quit unexpectedly".  I copied what I thought might be most specific.  (The suggested 'click to reopen' does not work) 
I hope this data from the details section is informative even if it is not the only exception type or code I have seen related to IDLE in similar conditions:

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000024

VM Regions Near 0x24:
--> 
    __TEXT                 0000000100000000-0000000100001000 [    4K] r-x/rwx SM=COW  /Library/Frameworks/Python.framework/Versions/3.2/Resources/Python.app/Contents/MacOS/Python

Application Specific Information:
Performing @selector(preferences:) from sender NSMenuItem 0x101b46a90
msg169744 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-09-03 05:17
David, can you verify that you do have ActiveTcl 8.5.12 (.0 or .1) installed and that the problem no longer occurs if you disable ActiveTk by moving it as described above?  When Preference is failing, the following Terminal shell command:

    grep TK_PATCH_LEVEL /Library/Frameworks/Tk.framework/Versions/Current/tkConfig.sh 

should output:
    TK_PATCH_LEVEL='.12'
msg169745 - (view) Author: David Pietz (David.Pietz) Date: 2012-09-03 05:31
ned,
That is exactly the output I received when I reverted to the ActiveState version, it failed and I ran your grep.
Thank You for your interest.
djp
msg169748 - (view) Author: David Pietz (David.Pietz) Date: 2012-09-03 05:52
I thank you, gentlemen, for your kind attention to my issue.  I hope it helps everyone in the long run.  
I, myself, became underwhelmed with these results of successfully opening preferences. I had been expecting to have a "|Startup|-|Shells open with command|text box to put a script in for append-logging my Python study in IDLE which follows Head First Python using 3.x- and its not in preferences for IDLE like it is in Terminal! 
Well, I guess I have some research to do on that matter.
Thanks again.  It was very gratifying to have my first issue responded to so quickly and intelligently!
msg169749 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-09-03 06:07
Hmm, sorry, I don't know of an easy fool-proof way to automatically log everything you type in IDLE.  But it's pretty easy to manually save the contents of the IDLE shell window at the end: with the keyboard focus on the Python Shell window, select the File -> Save menu option.  Good luck with exploring!
msg169852 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2012-09-05 01:02
I'm observed this happening on a number of machines at my client's site.  It started about three weeks ago and has not stopped (even with fresh installs of Py2.7.3 and ActiveTCL).  

I've not been able to figure-out why it affects some machines and not others.  It can happen on 10.6, 10.7, and 10.8.  I've hypothesized that some boxes have different XCode updates than others.
msg169863 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-09-05 08:49
The problem is a regression in the latest version of ActiveTcl 8.5 for OS X, specifically 8.5.12.1 (and I believe the previous version 8.5.12.0).  It has nothing directly to do with Python or how you might build Python other than whether _tkinter.so dynamically links with /Library/Frameworks/Tcl.framework/Verisons/8.5 and /Library/Framework/Tk.framework/Verisons/8.5 (the locations where ActiveTcl install) as opposed to /System/Library/Frameworks/Tcl.framework/... and /System/Library/Frameworks/Tk.framework/..., the Apple-supplied versions.  And, if so, which version of ActiveTcl you have installed.  The python.org 64-bit Pythons are vulnerable, the 32-bit-obly ones are not because they link with Tcl/Tk 8.4.

Unfortunately, ActiveState only makes available the most recent version of ActiveTcl on its Community Edition pages, so, unless you have access to a copy of an older version of ActiveTcl (like 8.5.11.1, the previous version), you're kind of stuck with the behavior, unless you remove ActiveTcl 8.5 and revert to Apple's Tk which is vulnerable to other crashes that have been fixed in ActiveState's (and is totally broken in OS X 10.6). Or you use the 32-bit installer and Tcl/Tk 8.4.  Or you build your own version of Tcl/Tk 8.5 (I've stared looking at that).  By the way, ActiveState's own ActivePython 2.7 also crashes the same way when using 8.5.12.x.  I've pinged the Tcl Mac mailing list.  Unless there's an immediate fix, I'll see what I can find in Tk.

http://permalink.gmane.org/gmane.comp.lang.tcl.mac/7080
msg172273 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-10-07 00:40
Ned, do you have any new information on this crasher? More people are having issues with TCL on Mac, e.g. #16156.
msg172277 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-07 00:52
While there isn't a fix available for Tk yet, there is now a viable workaround.  It turns out that ActiveState does make the last couple of their Community Edition ActiveTcl releases available if you know where to look for them.  So I've updated the information on http://www.python.org/getit/mac/tcltk/ to provide a link to the older 8.5.11.1 release (currently available at http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/) which does not have this problem.
msg172406 - (view) Author: David Pietz (David.Pietz) Date: 2012-10-08 19:59
It wasn't right on that page anymore but I poked around and fount the 8.5.11.1 and IDLE is no longer crashing when I go to preferences or when I cut and paste in the edit window (I didn't tell you about that did I ?- well it fixed that, too)!!

thanks solo much, Ned
msg172466 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-09 09:46
I've been able to build Cocoa Tk and isolate the crash regression to a particular Tk checkin.  This Tk issue contains the details: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=3575664&group_id=12997
msg172715 - (view) Author: Kevin Walzer (wordtech) * Date: 2012-10-12 03:08
The attached patch works around the crash for me on Python 2.7.3, Tk-Cocoa  8.5.12 (tip), on Lion.
msg172725 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-12 07:41
Thanks for the patch, Kevin. It does need to be updated a bit for the current 2.7 branch as there have been changes since 2.7.3.  Can you outline what you believe the problem is that your patch is trying to workaround?  Certainly, nothing that IDLE or any other tkinter-based application does should be able to cause a hard crash in Tk.  It seems very problematic to force a change to all existing versions of IDLE and require users to update their installed IDLEs just to work around a crash in the Cocoa Tk that was introduced by a specific recent checkin in Tk.  Since there have been other serious bugs in Cocoa Tk that have been corrected in every recent release of Cocoa Tk, it is pretty much incumbent on users to keep up with the latest available version.
msg172737 - (view) Author: Kevin Walzer (wordtech) * Date: 2012-10-12 10:37
The crash occurs during a "self.editFont.config" call, when the sample text in the font dialog is updated with new font properties. My changes re-structures the configure event to first create a tuple with new font properties, then apply that to the parent label widget's font. Same effect, works around the crash. 

My testing shows the crash occurs at the event loop level--somewhere in the event loop between Python, Tk, and Cocoa, this specific configuration causes Tk to barf and then crash. If you have followed the traffic on the event loop issues in Tk-Cocoa at SF and the Tcl-Mac list, you're aware that a) the event loop is fragile and complex and b) pretty much impossible to solve at this time because the only one who really understands it well, the original author of the code, is no longer involved with Tk development. As a result, it is often simpler to work around Tk-Cocoa event loop issues at the script level: that is what my patch does.  There is little chance of solving the crash at the Tk level at this time. 

I don't understand what the problem with in requesting that IDLE users update their installation to get this patch; it's no different than any other bug fix. As far as making sure it works with the various releases of Python, that's work that you or another Python dev will have to do. It's a two-line fix so I doubt it will be that complicated to implement. And yes, in an ideal world, it would be better to fix Tk, but this patch solve the immediate problem because we are not able to address this issue at the Tk level at this time.
msg172753 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-10-12 15:42
It appears that Kevin's patch is working around a bug in Tkinter's tkFont object configuration. I would suggest removing the editFont object entirely from configDialog if it is truly the root cause of Tk crashing.

Kevin, is the .textHighlightSample causing the crash or is the editFont.config line causing the crash?

Setting the font in the Fonts/Tab pane should also change the font in the Highlighting pane. This is part of issue14876. Would the following still work on your version of IDLE?

    newFont = (fontName, self.fontSize.get(), fontWeight)
    self.labelFontSample.config(font = newFont)
    self.textHighlightSample.configure(font=newFont)

Also, since this is a problem with Tk itself, can the crashing behavior be isolated into a small test script? I don't have a Mac to test with.
msg172908 - (view) Author: Kevin Walzer (wordtech) * Date: 2012-10-14 19:56
editFont.config is causing the crash. 

The revised patch you suggest configures both the display font example and the highlight-text example. We can certainly amend my patch along those lines.

I cannot reproduce the issue in simple Tcl/Tk using the equivalent [font create] and [font configure] calls. As noted, bugs involving the Tcl/Tk event loop on the Mac can be hard to reproduce. It is usually simpler, where possible, to work around the issue at the script level.
msg173134 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-17 06:31
I'm still not keen on working around a Tk crash by modifying IDLE especially when we know exactly which Tk change set caused the regression.  On the other hand, I sympathize with Kevin regarding the complexity of trying to track down and fix things involving event loops spanning Cocoa, Tk, Python, and IDLE and I do appreciate the effort you've put into debugging this and other Tk problems.  Thank you, Kevin.

So, if we're going to take the expedient approach, we need to come up with proper patches for 2.7, 3.2, 3.3, and default and then we need to test them for regressions with our other major supported platforms: Windows, some set of X11, OS X Carbon Tk 8.4, as well as the Cocoa Tk 8.5.  I can test the latter two.  I'd appreciate it if others could test the other platforms.  Roger, do you feel up to turning your suggestions into patches?  Once we're comfortable that the workaround works and doesn't cause other regressions, I can bug the ActiveState folks to push out a new release of ActiveTcl with fixes for some other problems and these fixes can go out in the next set of Python maintenance releases that should be coming up in the near future.
msg173310 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-19 07:35
The attached patch applies cleanly to default, 3.3, 3.2, and 2.7.  It appears to prevent the Tk crash observed with ActiveTcl 8.5.12.1 with all of them and I did not observe regressions when briefly tested on OS X with older versions of Tk 8.5 or Tk 8.4 nor on Linux with X11 Tk 8.5.  It still needs to be tested on Windows.
msg173431 - (view) Author: Pedro Meirelles (pedrommeirelles) Date: 2012-10-21 06:28
Hello,

I am biologist I am just starting to learn Python.

I have a mac and I am using OS X 10.8.2. I have installed Python 2.7.3 and when I try to copy and paste (use command) or go to preferences IDLE crashes. I did what Ned Deily said in msg169739:

sudo mv /Library/Frameworks/Tk.framework /Library/Frameworks/Tk_disabled

It worked. Now I can copy and paste in IDLE. But when I type quots (" or ') it crashes. 

What you think I can do to work in IDLE using both command and typing " and '?

Sorry if my question is too elementary.

I appreciate a lot all the comments and answers. It is very useful and enlightening.

Kind regards
msg173432 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-21 06:46
Pedro, try installing the older ActiveTcl 8.5.11.1 from here:
 
http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/

It is not perfect but does not have the Preferences regression and does have fixes for crashes when typing composite input characters.
msg173433 - (view) Author: Pedro Meirelles (pedrommeirelles) Date: 2012-10-21 06:50
Thank you very much, Ned!

It worked, awesome!

All the best

2012/10/20 Ned Deily <report@bugs.python.org>

>
> Ned Deily added the comment:
>
> Pedro, try installing the older ActiveTcl 8.5.11.1 from here:
>
> http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/
>
> It is not perfect but does not have the Preferences regression and does
> have fixes for crashes when typing composite input characters.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue15853>
> _______________________________________
>
msg173566 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-10-22 21:20
The patch works with 3.3.0 and 2.7.3 on Windows 7.

+1
msg173568 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-22 22:20
New changeset d089b8fb0f56 by Ned Deily in branch '2.7':
Issue #15853: Prevent IDLE crash on OS X when opening Preferences menu
http://hg.python.org/cpython/rev/d089b8fb0f56

New changeset a3d755eaf5fa by Ned Deily in branch '3.2':
Issue #15853: Prevent IDLE crash on OS X when opening Preferences menu
http://hg.python.org/cpython/rev/a3d755eaf5fa

New changeset 36e7da8d3059 by Ned Deily in branch '3.3':
Issue #15853: merge 3.2 -> 3.3
http://hg.python.org/cpython/rev/36e7da8d3059

New changeset 8f61d580aca6 by Ned Deily in branch 'default':
Issue #15853: merge 3.3 -> default
http://hg.python.org/cpython/rev/8f61d580aca6
msg173569 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-10-22 22:37
Thanks for everyone's help on this.  To summarize, opening IDLE's Preferences menu when Python is dynamically linking to ActiveTcl 8.5.12.1 (at this writing, the most recent version) causes Tk to crash.  The committed patches here avoid the crash by changing Tk calls from IDLE.  These fixes will be released in the next set of maintenance releases: 2.7.4, 3.2.4, 3.3.1, and in 3.4.0.  Until they are installed, another workaround is to revert to an earlier version of ActiveTcl; 8.5.11.1 is recommended:

    http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/

As always, http://www.python.org/download/mac/tcltk/ will be updated with current recommendations.
msg177958 - (view) Author: Vance Maverick (Vance.Maverick) Date: 2012-12-22 22:08
FYI, http://downloads.activestate.com/ActiveTcl/releases/8.5.11.1/ is no longer online, so that workaround is no longer possible.
msg178265 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-12-27 03:00
ActiveTcl 8.5.13 has now been released and, per ActiveState's usual practice of making only the current release and its immediate predecessor publicly downloadable, the ActiveTcl 8.5.11.1 release is no longer available at the URL above, as Vance noted.  8.5.13 includes fixes for other problems including another critical problem introduced in 8.5.12.x (Issue15574).  So, until the Python 3.3.1, 3.2.4, and 2.7.4 releases are available (which will include the workarounds for this issue) and if you do not have access to 8.5.11.1, one option is to patch IDLE yourself.

To assist in this, I have uploaded a shell script which will attempt to patch the python.org 3.3.0, 3.2.3, and 2.7.3 versions of IDLE if they are installed.  While I've tried to make it reasonably foolproof, examine and use at your own risk.  Download the attached file from this issue, patch_idle_issue_15853.sh, and run it in a terminal session.  It uses sudo so, on most systems, administrator access will be required.

See http://www.python.org/download/mac/tcltk/ for more information.
History
Date User Action Args
2022-04-11 14:57:35adminsetgithub: 60057
2012-12-27 03:00:06ned.deilysetmessages: + msg178265
2012-12-27 02:43:38ned.deilysetfiles: + patch_idle_issue_15853.sh
2012-12-22 22:08:41Vance.Mavericksetnosy: + Vance.Maverick
messages: + msg177958
2012-10-22 22:37:21ned.deilysetstatus: open -> closed
resolution: fixed
messages: + msg173569

stage: patch review -> resolved
2012-10-22 22:20:44python-devsetnosy: + python-dev
messages: + msg173568
2012-10-22 21:20:00roger.serwysetmessages: + msg173566
2012-10-21 06:50:27pedrommeirellessetmessages: + msg173433
2012-10-21 06:46:30ned.deilysetmessages: + msg173432
2012-10-21 06:28:34pedrommeirellessetnosy: + pedrommeirelles
messages: + msg173431
2012-10-19 07:35:35ned.deilysetfiles: + issue15853.patch

messages: + msg173310
stage: needs patch -> patch review
2012-10-17 06:31:48ned.deilysetstage: needs patch
messages: + msg173134
versions: + Python 3.4
2012-10-16 21:14:29asvetlovsetnosy: + asvetlov
2012-10-14 19:56:19wordtechsetmessages: + msg172908
2012-10-12 15:42:18roger.serwysetmessages: + msg172753
2012-10-12 10:37:30wordtechsetmessages: + msg172737
2012-10-12 07:41:34ned.deilysetmessages: + msg172725
2012-10-12 07:22:28ned.deilysetnosy: + roger.serwy
2012-10-12 03:23:56wordtechsetfiles: + configDialog.diff
2012-10-12 03:23:15wordtechsetfiles: - configDialog.diff
2012-10-12 03:08:17wordtechsetfiles: + configDialog.diff

nosy: + wordtech
messages: + msg172715

keywords: + patch
2012-10-09 09:46:24ned.deilysetmessages: + msg172466
2012-10-08 19:59:33David.Pietzsetmessages: + msg172406
2012-10-07 00:52:42ned.deilysetmessages: + msg172277
2012-10-07 00:40:18christian.heimessetnosy: + christian.heimes
messages: + msg172273
2012-09-26 16:11:23ned.deilylinkissue16054 superseder
2012-09-25 04:08:10ned.deilylinkissue16032 superseder
2012-09-05 08:49:36ned.deilysetmessages: + msg169863
2012-09-05 01:02:52rhettingersetnosy: + rhettinger
messages: + msg169852
2012-09-03 06:07:22ned.deilysetmessages: + msg169749
2012-09-03 05:52:42David.Pietzsetmessages: + msg169748
2012-09-03 05:31:29David.Pietzsetmessages: + msg169745
2012-09-03 05:17:52ned.deilysetmessages: + msg169744
2012-09-03 05:02:10David.Pietzsetfiles: + GRAB_IDLEquitUnexpectedly.tiff

messages: + msg169743
2012-09-03 04:28:45ned.deilysetassignee: ned.deily

components: + IDLE, macOS
title: Idle "quit unexpectedly" w/ attempted edit of preferences -> IDLE crashes selecting Preferences menu with OS X ActiveState Tcl/Tk 8.5.12.1
nosy: + ned.deily
versions: + Python 2.7, Python 3.3
messages: + msg169739
2012-09-03 00:34:19r.david.murraysetnosy: + r.david.murray
messages: + msg169733
2012-09-03 00:27:22David.Pietzcreate