Skip to content

Python with the 'TkAgg' backend on macOS crashes out when figure windows are moved #7743

@kghose

Description

@kghose

Bug summary
Python with the 'TkAgg' backend crashes out when figure windows are moved around between multiple monitors.

How to reproduce
Create a few figures e.g.:

from matplotlib import pyplot as plt
import numpy as np


def foo():
  plt.figure()
  plt.plot(np.random.randn(1000), np.random.randn(1000), 'k.')

for n in range(4):
  foo()

plt.show()

Move the figures between windows, rearrange them, swap between desktops, perhaps close the windows and rerun the script and repeat. There is a very high probability that Python will crash.

Actual outcome
IPython crashes with

2017-01-04 13:01:00.136 python[13315:466208] *** Assertion failure in -[_NSCGSWindow setFrame:], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.76/CGS.subproj/NSCGSWindow.m:663
2017-01-04 13:01:00.141 python[13315:466208] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: CGRectContainsRect(CGRectMake((CGFloat)INT_MIN, (CGFloat)INT_MIN, (CGFloat)INT_MAX - (CGFloat)INT_MIN, (CGFloat)INT_MAX - (CGFloat)INT_MIN), frame)'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff89111e7b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fff9dceccad objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff89116b82 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fff8ab60d50 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
	4   AppKit                              0x00007fff86d2f519 -[_NSCGSWindow setFrame:] + 252
	5   AppKit                              0x00007fff86dac644 _NXCreateWindowWithStyleMask + 157
	6   AppKit                              0x00007fff86dac4c2 _NSCreateWindow + 184
	7   AppKit                              0x00007fff86df5fe4 -[NSWindow _commonAwake] + 1465
	8   AppKit                              0x00007fff874a92d6 -[NSWindow _resolveAutomaticEnterFullScreenFlags] + 51
	9   AppKit                              0x00007fff86df58cf -[NSWindow makeKeyAndOrderFront:] + 31
	10  Tk                                  0x0000000106761487 XMapWindow + 164
	11  Tk                                  0x00000001066d2c9d Tk_MapWindow + 178
	12  Tk                                  0x00000001066db3c5 TkInstallFrameMenu + 271
	13  Tcl                                 0x000000010664ea57 TclServiceIdle + 77
	14  Tcl                                 0x0000000106635619 Tcl_DoOneEvent + 350
	15  _tkinter.so                         0x00000001065ab48d _tkinter_tkapp_mainloop + 445
	16  libpython3.5m.dylib                 0x000000010004ff38 PyCFunction_Call + 280
	17  libpython3.5m.dylib                 0x00000001000bd2df PyEval_EvalFrameEx + 22431
	18  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	19  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	20  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	21  libpython3.5m.dylib                 0x00000001000c192f fast_function + 207
	22  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	23  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	24  libpython3.5m.dylib                 0x00000001000b7b1e PyEval_EvalCodeEx + 78
	25  libpython3.5m.dylib                 0x000000010003430f function_call + 351
	26  libpython3.5m.dylib                 0x000000010000fd73 PyObject_Call + 99
	27  libpython3.5m.dylib                 0x000000010002130d method_call + 141
	28  libpython3.5m.dylib                 0x000000010000fd73 PyObject_Call + 99
	29  libpython3.5m.dylib                 0x0000000100064c55 slot_tp_call + 117
	30  libpython3.5m.dylib                 0x000000010000fd73 PyObject_Call + 99
	31  libpython3.5m.dylib                 0x00000001000bdec8 PyEval_EvalFrameEx + 25480
	32  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	33  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	34  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	35  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	36  libpython3.5m.dylib                 0x00000001000b7ac1 PyEval_EvalCode + 81
	37  libpython3.5m.dylib                 0x00000001000b52ab builtin_exec + 555
	38  libpython3.5m.dylib                 0x000000010004ff38 PyCFunction_Call + 280
	39  libpython3.5m.dylib                 0x00000001000bd2df PyEval_EvalFrameEx + 22431
	40  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	41  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	42  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	43  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	44  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	45  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	46  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	47  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	48  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	49  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	50  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	51  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	52  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	53  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	54  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	55  libpython3.5m.dylib                 0x00000001000c192f fast_function + 207
	56  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	57  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	58  libpython3.5m.dylib                 0x00000001000b7b1e PyEval_EvalCodeEx + 78
	59  libpython3.5m.dylib                 0x000000010003430f function_call + 351
	60  libpython3.5m.dylib                 0x000000010000fd73 PyObject_Call + 99
	61  libpython3.5m.dylib                 0x00000001000bdec8 PyEval_EvalFrameEx + 25480
	62  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	63  libpython3.5m.dylib                 0x00000001000c19ae fast_function + 334
	64  libpython3.5m.dylib                 0x00000001000bd434 PyEval_EvalFrameEx + 22772
	65  libpython3.5m.dylib                 0x00000001000c10c3 _PyEval_EvalCodeWithName + 1779
	66  libpython3.5m.dylib                 0x00000001000b7ac1 PyEval_EvalCode + 81
	67  libpython3.5m.dylib                 0x00000001000e6937 PyRun_FileExFlags + 215
	68  libpython3.5m.dylib                 0x00000001000e60ea PyRun_SimpleFileExFlags + 842
	69  libpython3.5m.dylib                 0x00000001000fcc5b Py_Main + 3355
	70  python                              0x0000000100000dc7 main + 215
	71  python                              0x0000000100000ce4 start + 52
	72  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

This is the most common form of stack trace, though more terse errors, such as

called Tcl_FindHashEntry on deleted table
Abort trap: 6

may be encountered.

Expected outcome
This kind of crash should not occur when we simply move windows from one monitor to the other.

Matplotlib version

  • matplotlib.version = 1.5.3 (installed via miniconda)
  • matplotlib.get_backend() == 'TkAgg'
  • Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:52:12)
  • IPython 5.1.0
  • Darwin MacBook-Pro.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy