Skip to content

Segmentation fault with MessageBox and FileDialog in the same script #99700

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

Closed
louis-martin opened this issue Nov 22, 2022 · 4 comments
Closed
Labels
OS-mac topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@louis-martin
Copy link

Bug report

Output received :

     zsh: segmentation fault  python3 test_dialogue.py

after the execution of the filedialog.

test_dialogue.py file content :

    import tkinter.filedialog
    import tkinter.messagebox
    
    fichier = tkinter.filedialog.askopenfilename()
    print(fichier)
    
    reponse = tkinter.messagebox.askyesnocancel(
        message='Êtes-vous certain ?', icon='question')
    print(reponse)

Each segment work well independantly.

Environment

Python 3.11.0
MAC OS Monrterey 12.6.1
MacBook Pro (13-inch, 2016, Four Thunderbolt 3 Ports)

@louis-martin louis-martin added the type-bug An unexpected behavior, bug, or error label Nov 22, 2022
@AlexWaygood AlexWaygood added topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump and removed type-bug An unexpected behavior, bug, or error labels Nov 22, 2022
@ronaldoussoren
Copy link
Contributor

The crash happens somewhere in Tk (see stack trace below), this might be a bug in the Tk library itself. See also #93042.

Stack trace from crash log
0   libobjc.A.dylib               	       0x1aa4ba810 object_getClass + 48
1   Foundation                    	       0x1ab7dfe00 _NSKeyValueObservationInfoGetObservances + 248
2   Foundation                    	       0x1ab7d0b7c -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 240
3   Foundation                    	       0x1ab7dfb14 -[NSObject(NSKeyValueObservingPrivate) _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 720
4   CoreFoundation                	       0x1aa8c638c -[CFPrefsSource forEachObserver:] + 316
5   CoreFoundation                	       0x1aa9033ac -[CFPrefsSource _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 112
6   CoreFoundation                	       0x1aa903218 ___CFPrefsDeliverPendingKVONotificationsGuts_block_invoke + 432
7   CoreFoundation                	       0x1aa90305c __CFDictionaryApplyFunction_block_invoke + 28
8   CoreFoundation                	       0x1aa8cafec CFBasicHashApply + 148
9   CoreFoundation                	       0x1aa8bcbc8 CFDictionaryApplyFunction + 320
10  CoreFoundation                	       0x1aa902fd0 _CFPrefsDeliverPendingKVONotificationsGuts + 300
11  CoreFoundation                	       0x1aa8ad514 -[_CFXPreferences _deliverPendingKVONotifications] + 96
12  CoreFoundation                	       0x1aa9fa7d4 -[_CFXPreferences withNamedVolatileSourceForIdentifier:perform:] + 340
13  CoreFoundation                	       0x1aa8c4370 __41-[_CFXPreferences registerDefaultValues:]_block_invoke + 128
14  CoreFoundation                	       0x1aa8ac5d0 withKeysAndValues + 292
15  CoreFoundation                	       0x1aa8c42c8 -[_CFXPreferences registerDefaultValues:] + 116
16  CoreFoundation                	       0x1aa8c421c _CFXPreferencesRegisterDefaultValues + 80
17  Metal                         	       0x1b3ad7a5c invocation function for block in initWrapperType() + 100
18  libdispatch.dylib             	       0x1aa69b504 _dispatch_client_callout + 20
19  libdispatch.dylib             	       0x1aa69cd50 _dispatch_once_callout + 32
20  Metal                         	       0x1b3ad79d4 invocation function for block in MTLDeviceArrayInitialize() + 1284
21  libdispatch.dylib             	       0x1aa69b504 _dispatch_client_callout + 20
22  libdispatch.dylib             	       0x1aa69cd50 _dispatch_once_callout + 32
23  Metal                         	       0x1b3ab0684 MTLCopyAllDevices + 244
24  CoreImage                     	       0x1b4615078 CIMetalCopyDefaultDevice + 88
25  CoreImage                     	       0x1b46b367c invocation function for block in can_use_metal() + 40
26  libdispatch.dylib             	       0x1aa69b504 _dispatch_client_callout + 20
27  libdispatch.dylib             	       0x1aa69cd50 _dispatch_once_callout + 32
28  CoreImage                     	       0x1b461a450 -[CIContext initWithOptions:] + 832
29  CoreUI                        	       0x1b2315808 __38+[CUIShapeEffectStack sharedCIContext]_block_invoke + 56
30  libdispatch.dylib             	       0x1aa69b504 _dispatch_client_callout + 20
31  libdispatch.dylib             	       0x1aa69cd50 _dispatch_once_callout + 32
32  CoreUI                        	       0x1b23157cc +[CUIShapeEffectStack sharedCIContext] + 64
33  CoreUI                        	       0x1b232b1e4 -[CUIShapeEffectStack newFlattenedImageFromShapeCGImage:withScale:cache:] + 188
34  CoreUI                        	       0x1b231bce4 -[CUIThemeFacet updateLayer:effects:] + 676
35  CoreUI                        	       0x1b239b2f4 CUICoreThemeRenderer::CreateOrUpdatePushButtonOrBevelButtonRoundLayer(CUIRenditionKey*, CUIDescriptor const*, CALayer**) + 292
36  CoreUI                        	       0x1b231a290 CUICoreThemeRenderer::CreateOrUpdateLayer(CUIDescriptor const*, CALayer**) + 564
37  CoreUI                        	       0x1b2319fe8 CUIRenderer::CreateOrUpdateLayer(__CFDictionary const*, CALayer**) + 260
38  AppKit                        	       0x1adb612f8 -[NSCompositeAppearance _callCoreUIWithBlock:options:requireBezelTintColor:] + 284
39  AppKit                        	       0x1adb778ac -[NSAppearance _createOrUpdateLayer:options:] + 100
40  AppKit                        	       0x1adbff2c4 _withOverlaidDictionary + 156
41  AppKit                        	       0x1adfa4aa8 -[NSWidgetView _updateWidgetLayers] + 212
42  AppKit                        	       0x1adbffab4 -[NSWidgetView layout] + 28
43  AppKit                        	       0x1ae325328 ___NSViewLayout_block_invoke + 592
44  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
45  AppKit                        	       0x1adba0830 _NSViewLayout + 96
46  AppKit                        	       0x1ae31bc9c __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 364
47  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
48  AppKit                        	       0x1adba07c4 -[NSView _layoutSubtreeWithOldSize:] + 100
49  AppKit                        	       0x1ae31bde0 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 688
50  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
51  AppKit                        	       0x1adba07c4 -[NSView _layoutSubtreeWithOldSize:] + 100
52  AppKit                        	       0x1ae31bde0 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 688
53  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
54  AppKit                        	       0x1adba07c4 -[NSView _layoutSubtreeWithOldSize:] + 100
55  AppKit                        	       0x1ae31bde0 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 688
56  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
57  AppKit                        	       0x1adba07c4 -[NSView _layoutSubtreeWithOldSize:] + 100
58  AppKit                        	       0x1ae48e178 -[NSTouchBarView _layoutSubtreeWithOldSize:] + 80
59  AppKit                        	       0x1ae31bde0 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 688
60  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
61  AppKit                        	       0x1adba07c4 -[NSView _layoutSubtreeWithOldSize:] + 100
62  AppKit                        	       0x1ae31bde0 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 688
63  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
64  AppKit                        	       0x1adba07c4 -[NSView _layoutSubtreeWithOldSize:] + 100
65  AppKit                        	       0x1ae31c7a0 __56-[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:]_block_invoke + 800
66  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
67  AppKit                        	       0x1adba0314 -[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 100
68  AppKit                        	       0x1adb9b6cc NSPerformVisuallyAtomicChange + 108
69  AppKit                        	       0x1adba02a4 -[NSView layoutSubtreeIfNeeded] + 96
70  AppKit                        	       0x1ae568c98 -[NSWindow(NSConstraintBasedLayoutInternal) _layoutViewTree] + 104
71  AppKit                        	       0x1ae568e20 -[NSWindow(NSConstraintBasedLayoutInternal) layoutIfNeeded] + 240
72  AppKit                        	       0x1adbff718 __NSWindowGetDisplayCycleObserverForLayout_block_invoke + 364
73  AppKit                        	       0x1adbfecb4 NSDisplayCycleObserverInvoke + 168
74  AppKit                        	       0x1adbfe910 NSDisplayCycleFlush + 644
75  QuartzCore                    	       0x1b1f46120 CA::Transaction::run_commit_handlers(CATransactionPhase) + 120
76  QuartzCore                    	       0x1b1f44ea0 CA::Transaction::commit() + 324
77  AppKit                        	       0x1adc80b90 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 272
78  AppKit                        	       0x1ae35d744 ___NSRunLoopObserverCreateWithHandler_block_invoke + 64
79  CoreFoundation                	       0x1aa900de4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
80  CoreFoundation                	       0x1aa900cd0 __CFRunLoopDoObservers + 532
81  CoreFoundation                	       0x1aa900308 __CFRunLoopRun + 784
82  CoreFoundation                	       0x1aa8ff8a4 CFRunLoopRunSpecific + 612
83  HIToolbox                     	       0x1b3f733bc RunCurrentEventLoopInMode + 292
84  HIToolbox                     	       0x1b3f7304c ReceiveNextEventCommon + 236
85  HIToolbox                     	       0x1b3f72f48 _BlockUntilNextEventMatchingListInModeWithFilter + 72
86  AppKit                        	       0x1adb58630 _DPSNextEvent + 632
87  AppKit                        	       0x1adb577c0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
88  AppKit                        	       0x1add91ec8 -[NSApplication _doModalLoop:peek:] + 216
89  AppKit                        	       0x1add90dd8 __35-[NSApplication runModalForWindow:]_block_invoke_2 + 56
90  AppKit                        	       0x1add90d84 __35-[NSApplication runModalForWindow:]_block_invoke + 108
91  AppKit                        	       0x1add90668 _NSTryRunModal + 100
92  AppKit                        	       0x1add90528 -[NSApplication runModalForWindow:] + 292
93  AppKit                        	       0x1adec94cc __19-[NSAlert runModal]_block_invoke_2 + 120
94  AppKit                        	       0x1adec9438 __19-[NSAlert runModal]_block_invoke + 108
95  AppKit                        	       0x1add90668 _NSTryRunModal + 100
96  AppKit                        	       0x1ade03654 -[NSAlert runModal] + 140
97  libtk8.6.dylib                	       0x104ac86d4 Tk_MessageBoxObjCmd + 1764
98  libtcl8.6.dylib               	       0x104cf72a8 TclNRRunCallbacks + 80
99  _tkinter.cpython-311-darwin.so	       0x10468d348 Tkapp_Call + 336

@chrstphrchvz
Copy link
Contributor

I can reproduce this issue under Python’s bundled Tcl/Tk 8.6.12. Using LLDB to jump over the [NSApp _resetAutoreleasePool] call removed in Tcl/Tk 8.6.13 (see https://core.tcl-lang.org/tk/info/d638e7ca3616) prevents this issue. So I believe the fix for #92603 also applies to this issue.

@chrstphrchvz
Copy link
Contributor

I can reproduce this issue under Python’s bundled Tcl/Tk 8.6.12. Using LLDB to jump over the [NSApp _resetAutoreleasePool] call removed in Tcl/Tk 8.6.13 (see https://core.tcl-lang.org/tk/info/d638e7ca3616) prevents this issue. So I believe the fix for #92603 also applies to this issue.

Sorry, the crash is still possible in Tk Aqua 8.6.13. The change I mentioned does seem to prevent the crash, but it does not eliminate it completely.

@louis-martin
Copy link
Author

The crash is still possible with Python 3.11.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-mac topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

4 participants