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-related segfault on macOS (regression between 3.7.0 and 3.7.1rc1) #79108

Closed
aivarannamaa mannequin opened this issue Oct 8, 2018 · 12 comments
Closed

Tkinter-related segfault on macOS (regression between 3.7.0 and 3.7.1rc1) #79108

aivarannamaa mannequin opened this issue Oct 8, 2018 · 12 comments
Assignees
Labels

Comments

@aivarannamaa
Copy link
Mannequin

aivarannamaa mannequin commented Oct 8, 2018

BPO 34927
Nosy @ned-deily, @tirkarthi, @aivarannamaa

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 = 'https://github.com/ned-deily'
closed_at = <Date 2018-10-14.02:02:39.220>
created_at = <Date 2018-10-08.07:32:02.211>
labels = ['3.7', 'expert-tkinter']
title = 'Tkinter-related segfault on macOS (regression between 3.7.0 and 3.7.1rc1)'
updated_at = <Date 2018-10-14.06:13:14.330>
user = 'https://github.com/aivarannamaa'

bugs.python.org fields:

activity = <Date 2018-10-14.06:13:14.330>
actor = 'xtreak'
assignee = 'ned.deily'
closed = True
closed_date = <Date 2018-10-14.02:02:39.220>
closer = 'ned.deily'
components = ['Tkinter']
creation = <Date 2018-10-08.07:32:02.211>
creator = 'aivarannamaa'
dependencies = []
files = []
hgrepos = []
issue_num = 34927
keywords = []
message_count = 12.0
messages = ['327326', '327327', '327328', '327329', '327330', '327331', '327332', '327333', '327668', '327670', '327687', '327692']
nosy_count = 3.0
nosy_names = ['ned.deily', 'xtreak', 'aivarannamaa']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue34927'
versions = ['Python 3.7']

@aivarannamaa
Copy link
Mannequin Author

aivarannamaa mannequin commented Oct 8, 2018

After switching from Python 3.7.0 to 3.7.1rc1 (macOS, 64-bit only downloaded from python.org), my rather big Tkinter application started to segfault whenever I close a system dialog (eg. the one created by askopenfilename or showerror) by keypress (eg. Escape or Enter). The crash does not happen when I close the dialog with mouse click.

The code that calls the dialog runs fine, and the crash seems to happen next time the control goes back to Tk mainloop. It looks like the keypress performed in the dialog somehow remains in Tk event queue.

Here is the system log for main thread, (more detailed information can be seen at https://bitbucket.org/plas/thonny/issues/545/quit):

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

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

VM Regions Near 0:
-->
__TEXT 000000010ab7e000-000000010ab7f000 [ 4K] r-x/rwx SM=COW /Users/USER/Desktop/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff97e1a8ea __kill + 10
1 libsystem_platform.dylib 0x00007fff96dba52a _sigtramp + 26
2 ??? 000000000000000000 0 + 0
3 libtk8.6.dylib 0x000000010b876e84 -[TKApplication(TKKeyEvent) tkProcessKeyEvent:] + 160
4 libtk8.6.dylib 0x000000010b87d6d9 TkMacOSXEventsCheckProc + 360
5 libtcl8.6.dylib 0x000000010b714d06 Tcl_DoOneEvent + 316
6 _tkinter.cpython-37m-darwin.so 0x000000010b64501d _tkinter_tkapp_mainloop + 269
7 org.python.python 0x000000010aba752e _PyMethodDef_RawFastCallKeywords + 430
8 org.python.python 0x000000010abad192 _PyMethodDescr_FastCallKeywords + 82
9 org.python.python 0x000000010ac6640c call_function + 780
10 org.python.python 0x000000010ac6339c _PyEval_EvalFrameDefault + 25164
11 org.python.python 0x000000010ac66f06 _PyEval_EvalCodeWithName + 2422
12 org.python.python 0x000000010aba6a61 _PyFunction_FastCallKeywords + 257
13 org.python.python 0x000000010ac663e2 call_function + 738
14 org.python.python 0x000000010ac633b6 _PyEval_EvalFrameDefault + 25190
15 org.python.python 0x000000010aba6ed0 function_code_fastcall + 128
16 org.python.python 0x000000010ac663e2 call_function + 738
17 org.python.python 0x000000010ac63457 _PyEval_EvalFrameDefault + 25351
18 org.python.python 0x000000010ac66f06 _PyEval_EvalCodeWithName + 2422
19 org.python.python 0x000000010ac5d074 PyEval_EvalCode + 100
20 org.python.python 0x000000010ac5a65d builtin_exec + 557
21 org.python.python 0x000000010aba752e _PyMethodDef_RawFastCallKeywords + 430
22 org.python.python 0x000000010aba6a9a _PyCFunction_FastCallKeywords + 42
23 org.python.python 0x000000010ac663d4 call_function + 724
24 org.python.python 0x000000010ac63457 _PyEval_EvalFrameDefault + 25351
25 org.python.python 0x000000010ac66f06 _PyEval_EvalCodeWithName + 2422
26 org.python.python 0x000000010aba6a61 _PyFunction_FastCallKeywords + 257
27 org.python.python 0x000000010ac663e2 call_function + 738
28 org.python.python 0x000000010ac63457 _PyEval_EvalFrameDefault + 25351
29 org.python.python 0x000000010ac66f06 _PyEval_EvalCodeWithName + 2422
30 org.python.python 0x000000010aba663b _PyFunction_FastCallDict + 523
31 org.python.python 0x000000010acb8743 pymain_run_module + 147
32 org.python.python 0x000000010acb7b47 pymain_main + 5303
33 org.python.python 0x000000010acb868a _Py_UnixMain + 58
34 libdyld.dylib 0x00007fff921c35ad start + 1

@aivarannamaa aivarannamaa mannequin added 3.7 (EOL) end of life topic-tkinter labels Oct 8, 2018
@aivarannamaa
Copy link
Mannequin Author

aivarannamaa mannequin commented Oct 8, 2018

Here is a simple application that also exposes this problem. Click at the button and press Escape when dialog appears.

import tkinter as tk
import tkinter.filedialog as fd
 
root = tk.Tk()
 
def dostuff():
    fd.askopenfile()
 
bt = tk.Button(root, text="Click me!", command=dostuff)
bt.grid()
 
root.mainloop()

@aivarannamaa
Copy link
Mannequin Author

aivarannamaa mannequin commented Oct 8, 2018

Looks like the workaround is to provide explicit parent named argument to the dialog call.

@tirkarthi
Copy link
Member

Thanks for the report and script. I can't reproduce this with 3.7.1rc1 tag and also tried this on v3.7.0 which works fine on Mac OS running 10.10.4 and tcl version 8.5 . I checked out the 3.7.1rc1 tag and did a clean rebuild with git clean -xdf && ./configure --with-pydebug && make -s -j4 and tried below

Steps I followed :

  • I executed the script.
  • clicked on "click me" button.
  • A file open dialog opened and I closed this with esc.
  • Again clicked "click me" button and selected a file to click enter the file open dialog disappeared
  • Closed the main box with "click me". No segfault.

Since the report says it's a regression between 3.7.0 and 3.7.1RC1 I am adding Ned as a friendly ping about this issue so that this can be tracked better between RC releases.

@aivarannamaa
Copy link
Mannequin Author

aivarannamaa mannequin commented Oct 8, 2018

I got the segfault with Tk 8.6, provided with python.org installer.

@tirkarthi
Copy link
Member

Thanks, I can confirm that this works with 3.7.0 and segfaults with 3.7.1RC1 Mac OS installer that uses Tk 8.6 . Clicking the button and closing the file open dialog triggers this segfault as noted in your description. I don't know how I can configure my local build to use Tk 8.6 and maybe it's a problem with Tk 8.6. It seems from 3.7 and above the installer uses 8.6 while 3.6 dynamically links to the apple's version 8.5 as noted in https://www.python.org/download/mac/tcltk/#built-in-8-6-8

@aivarannamaa
Copy link
Mannequin Author

aivarannamaa mannequin commented Oct 8, 2018

Can it be caused by adf4932 ?

@ned-deily
Copy link
Member

Can it be caused by adf4932 ?

It very likely could be. Thanks for the report. I'll take a look at it a bit later.

@ned-deily ned-deily self-assigned this Oct 8, 2018
@ned-deily
Copy link
Member

New changeset f55c3ae by Ned Deily in branch '3.6':
bpo-34370: Revert to using released Tk 8.6.8 with macOS installers
f55c3ae

@ned-deily
Copy link
Member

New changeset d8b6425 by Ned Deily in branch '3.7':
bpo-34370: Revert to using released Tk 8.6.8 with macOS installers
d8b6425

@ned-deily
Copy link
Member

It appears that the segfault behavior *was* introduced by some change in the Tk 8.6 development snapshot I chose to use for the python.org macOS installer builds in 3.7.1rc1 and 3.6.7rc2. For 3.7.1rc2 and 3.6.7rc2, I reverted back to using the standard Tk 8.6.8 release and the segfault seems to have gone away on the systems where I was able to reproduce it with rc1 - whether it segfaulted seems to be system dependent. We'll probably wait for the official release of Tk 8.6.9 before trying to upgrade Tk again. Let us know if the problem reappears.

@tirkarthi
Copy link
Member

Thanks for the release Ned. I can confirm that there is no segfault with Python 3.7.1rc2 (v3.7.1rc2:6c06ef7dc3).

@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
Projects
None yet
Development

No branches or pull requests

2 participants