QMessageBox crash on macOS 27.0.1
-
Hello,
Since upgrade to macOS 27.0.1 this simple code is crashing with PyQt6 when trying to display the QMessageBox:
import sys from PyQt6.QtWidgets import ( QApplication, QWidget, QPushButton, QMessageBox, QVBoxLayout, ) app = QApplication(sys.argv) window = QWidget() window .setWindowTitle("Sample") button = QPushButton("Display") def display_dialog(): QMessageBox.question( window, "Confirmation", "Continue ?", QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel, QMessageBox.StandardButton.Cancel, ) button .clicked.connect(display_dialog) layout = QVBoxLayout() layout.addWidget(button) window.setLayout(layout) window .show() sys.exit(app.exec())As workaround this works:
import sys from PyQt6.QtWidgets import ( QApplication, QWidget, QPushButton, QMessageBox, QVBoxLayout, ) app = QApplication(sys.argv) window = QWidget() window.setWindowTitle("Sample") button = QPushButton("Display") def display_dialog(): dialog = QMessageBox(window) dialog.setOption(QMessageBox.Option.DontUseNativeDialog, True) dialog.setWindowTitle("Confirmation") dialog.setText("Continue ?") dialog.setStandardButtons( QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel ) dialog.exec() button.clicked.connect(display_dialog) layout = QVBoxLayout(window) layout.addWidget(button) window.show() sys.exit(app.exec())So it looks like usage of native dialog box is broken with macOS 27.0.1.
Is this a known issue? If not, can anybody reports this to Qt developers?Thanks
-
Is there maybe some relationship between this and https://forum.qt.io/topic/165172/qfontdialog-on-macos-27-isn-t-modal-anymore ? Maybe there is an issue with native dialog changes?
-
Unlikely, the internal mechanism is different, and I furthermore cannot reproduce any crash with OP's sample.
@Qoissi Please provide more detail - which version of Qt and which version of PyQt? Is the crash due to a Python exception or in native code? Can you provide a stack trace?
-
Hi, sorry it was difficult to get the details because I do not have means to reproduce myself (I'm reporting issues communicated by users of my PyQt6 based program).
Here are the versions used:
PyQt6 6.11.0 PyQt6-Qt6 6.11.2 PyQt6_sip 13.11.0 Python 3.12.12The crash is not due to a Python exception, this is in native code.
As of today the user has not been able to provide a stack trace...But another user, still of macOS 27.0.1 and also using PyQt6 6.11.0 reports this stack when displaying a dialog (not sure this is a QMessageBox).
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: targetSizeInPoints.width>0 && targetSizeInPoints.height>0' *** First throw call stack: ( 0 CoreFoundation 0x000000018c5aa8c0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018c00860c objc_exception_throw + 88 2 Foundation 0x000000018dcf14d8 -[NSCalendarDate initWithCoder:] + 0 3 CoreUI 0x00000001971a0608 -[CUINamedVectorGlyph _rasterizeImageUsingScaleFactor:forTargetSize:renderingMode:colorResolver:] + 184 4 CoreUI 0x00000001970d0098 __64-[CUINamedVectorGlyph _imageForRenderingMode:withColorResolver:]_block_invoke + 1316 5 CoreUI 0x00000001971a0318 -[CUINamedVectorGlyph _performWithLockedRenditions:] + 192 6 CoreUI 0x00000001970cca7c -[CUINamedVectorGlyph _imageForRenderingMode:withColorResolver:] + 136 7 CoreUI 0x00000001970bbac4 -[CUINamedVectorGlyph image] + 124 8 RenderBox 0x00000001b354f374 _ZNK2RB6Symbol12Presentation14template_imageEv + 560 9 RenderBox 0x00000001b35f0eec RBSymbolUpdateTemplateImage + 36 10 SwiftUICore 0x0000000230653404 $s7SwiftUI020_ShapeStyle_RenderedC0V17renderVectorGlyph33_3890C65F12EA82A4BC5FBD33046B67FALL_4size11orientation4name6styles6layersyAA08ResolvedgH0V_So6CGSizeVAA5ImageV11OrientationOAA01_cD5_NameO 11 SwiftUICore 0x000000023064812c $s7SwiftUI020_ShapeStyle_RenderedC0V10renderItem4name6styles6layersyAA01_cD5_NameO_AA01_cD5_PackVyXKAA01_cd1_E6LayersVztF + 644 12 SwiftUICore 0x0000000230172620 $s7SwiftUI22ShapeStyledDisplayList33_E1641985C375D8826E6966D4F238A1B8LLV11updateValueyyFAA5ImageVAAE8ResolvedV_Tg5 + 2200 13 SwiftUICore 0x000000023023d338 $s14AttributeGraph0A0VyACyxGqd__c5ValueQyd__RszAA12StatefulRuleRd__lufcADSPyqd__GXEfU_ySv_So11AGAttributeatcyXEfU_ySv_AJtcfu_7SwiftUI11DisplayListV_AK011ShapeStylediJ033_E1641985C375D8826E6966D4F 14 AttributeGraph 0x00000001c6255ef8 _ZN2AG5Graph11UpdateStack6updateEv + 528 15 AttributeGraph 0x00000001c6256688 _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 356 16 AttributeGraph 0x00000001c625e720 _ZN2AG5Graph20input_value_ref_slowENS_4data3ptrINS_4NodeEEENS_11AttributeIDEjjPK15AGSwiftMetadataRhl + 588 17 AttributeGraph 0x00000001c6277100 AGGraphGetValue + 268 18 SwiftUICore 0x0000000230230978 $s7SwiftUI23InterpolatedDisplayList33_7377A3587909D054D379011E12826F37LLV11updateValueyyFAA5ImageVAAE8ResolvedV_Tg5 + 1908 19 SwiftUICore 0x000000023023d2f0 $s14AttributeGraph0A0VyACyxGqd__c5ValueQyd__RszAA12StatefulRuleRd__lufcADSPyqd__GXEfU_ySv_So11AGAttributeatcyXEfU_ySv_AJtcfu_7SwiftUI11DisplayListV_AK012InterpolatediJ033_7377A3587909D054D379011E 20 AttributeGraph 0x00000001c6255ef8 _ZN2AG5Graph11UpdateStack6updateEv + 528 21 AttributeGraph 0x00000001c626594c ZN2AG8Subgraph6updateEj + 944 22 SwiftUICore 0x0000000230975178 $s7SwiftUI9GraphHostC14runTransactionyyF + 208 23 SwiftUICore 0x0000000230eceef0 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tF + 152 24 SwiftUICore 0x0000000230ec87b8 $s7SwiftUI25ViewGraphRootValueUpdaterPAAE6render8interval17updateDisplayList15targetTimestampySd_SbAA4TimeVSgtFyyXEfU + 776 25 SwiftUICore 0x0000000230ec6a84 $s7SwiftUI25ViewGraphRootValueUpdaterPAAE6render8interval17updateDisplayList15targetTimestampySd_SbAA4TimeVSgtF + 608 26 AppKit 0x0000000191a225f4 __swift_closure_destructor.11 + 16084 27 AppKit 0x000000019192ca70 __swift_memcpy0_1 + 252 28 AppKit 0x0000000190e2a9d8 -[NSApplication _terminateFromSender:askIfShouldTerminate:saveWindows:] + 66988 29 AppKit 0x0000000190b07280 +[NSAnimationContext runAnimationGroup:] + 56 30 AppKit 0x0000000191a1f230 __swift_closure_destructor.11 + 2832 31 AppKit 0x0000000191a1084c __swift__destructor.144 + 5860 32 AppKit 0x0000000191a10880 __swift__destructor.144 + 5912 33 AppKit 0x0000000191b04228 __swift__destructor.26 + 260 34 AppKit 0x0000000191b04250 __swift__destructor.26 + 300 35 AppKit 0x0000000191bb52b0 __swift_memcpy18_8 + 11648 36 AppKit 0x0000000191bb58ac __swift_memcpy18_8 + 13180 37 AppKit 0x0000000191523ab8 ___NSViewLayout_block_invoke + 644 38 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 39 AppKit 0x0000000190b364a8 _NSViewLayout + 96 40 AppKit 0x0000000191518bb4 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 380 41 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 42 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 43 AppKit 0x0000000191518cf8 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 704 44 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 45 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 46 AppKit 0x0000000191518cf8 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 704 47 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 48 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 49 AppKit 0x0000000191518cf8 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 704 50 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 51 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 52 AppKit 0x0000000191519748 __56-[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:]_block_invoke + 876 53 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 54 AppKit 0x0000000190b3600c -[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 100 55 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 56 AppKit 0x0000000190b35f9c -[NSView layoutSubtreeIfNeeded] + 96 57 AppKit 0x0000000191830754 -[NSWindow(NSConstraintBasedLayoutInternal) _layoutViewTree] + 108 58 AppKit 0x0000000191830950 -[NSWindow(NSConstraintBasedLayoutInternal) layoutIfNeeded] + 240 59 AppKit 0x0000000190b95ca8 __NSWindowGetDisplayCycleObserverForLayout_block_invoke + 364 60 AppKit 0x0000000190b951d8 NSDisplayCycleObserverInvoke + 152 61 AppKit 0x0000000190b94e64 NSDisplayCycleFlush + 656 62 QuartzCore 0x0000000196bc108c _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 120 63 QuartzCore 0x0000000196bbf68c _ZN2CA11Transaction6commitEv + 324 64 QuartzCore 0x0000000196bbf370 _ZN2CA11Transaction5flushEv + 84 65 AppKit 0x0000000190d1a258 _NSTryRunModal + 60 66 AppKit 0x0000000190d872d4 -[NSAlert runModal] + 196 67 libqcocoa.dylib 0x0000000113abb0e8 qt_plugin_instan libc++abi: terminating due to uncaught exception of type NSException zsh: abortThanks.
-
Hi,
Can you check with the latest version of PySide6 to see if you experience the same crash ? -
Hi, sorry it was difficult to get the details because I do not have means to reproduce myself (I'm reporting issues communicated by users of my PyQt6 based program).
Here are the versions used:
PyQt6 6.11.0 PyQt6-Qt6 6.11.2 PyQt6_sip 13.11.0 Python 3.12.12The crash is not due to a Python exception, this is in native code.
As of today the user has not been able to provide a stack trace...But another user, still of macOS 27.0.1 and also using PyQt6 6.11.0 reports this stack when displaying a dialog (not sure this is a QMessageBox).
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: targetSizeInPoints.width>0 && targetSizeInPoints.height>0' *** First throw call stack: ( 0 CoreFoundation 0x000000018c5aa8c0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018c00860c objc_exception_throw + 88 2 Foundation 0x000000018dcf14d8 -[NSCalendarDate initWithCoder:] + 0 3 CoreUI 0x00000001971a0608 -[CUINamedVectorGlyph _rasterizeImageUsingScaleFactor:forTargetSize:renderingMode:colorResolver:] + 184 4 CoreUI 0x00000001970d0098 __64-[CUINamedVectorGlyph _imageForRenderingMode:withColorResolver:]_block_invoke + 1316 5 CoreUI 0x00000001971a0318 -[CUINamedVectorGlyph _performWithLockedRenditions:] + 192 6 CoreUI 0x00000001970cca7c -[CUINamedVectorGlyph _imageForRenderingMode:withColorResolver:] + 136 7 CoreUI 0x00000001970bbac4 -[CUINamedVectorGlyph image] + 124 8 RenderBox 0x00000001b354f374 _ZNK2RB6Symbol12Presentation14template_imageEv + 560 9 RenderBox 0x00000001b35f0eec RBSymbolUpdateTemplateImage + 36 10 SwiftUICore 0x0000000230653404 $s7SwiftUI020_ShapeStyle_RenderedC0V17renderVectorGlyph33_3890C65F12EA82A4BC5FBD33046B67FALL_4size11orientation4name6styles6layersyAA08ResolvedgH0V_So6CGSizeVAA5ImageV11OrientationOAA01_cD5_NameO 11 SwiftUICore 0x000000023064812c $s7SwiftUI020_ShapeStyle_RenderedC0V10renderItem4name6styles6layersyAA01_cD5_NameO_AA01_cD5_PackVyXKAA01_cd1_E6LayersVztF + 644 12 SwiftUICore 0x0000000230172620 $s7SwiftUI22ShapeStyledDisplayList33_E1641985C375D8826E6966D4F238A1B8LLV11updateValueyyFAA5ImageVAAE8ResolvedV_Tg5 + 2200 13 SwiftUICore 0x000000023023d338 $s14AttributeGraph0A0VyACyxGqd__c5ValueQyd__RszAA12StatefulRuleRd__lufcADSPyqd__GXEfU_ySv_So11AGAttributeatcyXEfU_ySv_AJtcfu_7SwiftUI11DisplayListV_AK011ShapeStylediJ033_E1641985C375D8826E6966D4F 14 AttributeGraph 0x00000001c6255ef8 _ZN2AG5Graph11UpdateStack6updateEv + 528 15 AttributeGraph 0x00000001c6256688 _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 356 16 AttributeGraph 0x00000001c625e720 _ZN2AG5Graph20input_value_ref_slowENS_4data3ptrINS_4NodeEEENS_11AttributeIDEjjPK15AGSwiftMetadataRhl + 588 17 AttributeGraph 0x00000001c6277100 AGGraphGetValue + 268 18 SwiftUICore 0x0000000230230978 $s7SwiftUI23InterpolatedDisplayList33_7377A3587909D054D379011E12826F37LLV11updateValueyyFAA5ImageVAAE8ResolvedV_Tg5 + 1908 19 SwiftUICore 0x000000023023d2f0 $s14AttributeGraph0A0VyACyxGqd__c5ValueQyd__RszAA12StatefulRuleRd__lufcADSPyqd__GXEfU_ySv_So11AGAttributeatcyXEfU_ySv_AJtcfu_7SwiftUI11DisplayListV_AK012InterpolatediJ033_7377A3587909D054D379011E 20 AttributeGraph 0x00000001c6255ef8 _ZN2AG5Graph11UpdateStack6updateEv + 528 21 AttributeGraph 0x00000001c626594c ZN2AG8Subgraph6updateEj + 944 22 SwiftUICore 0x0000000230975178 $s7SwiftUI9GraphHostC14runTransactionyyF + 208 23 SwiftUICore 0x0000000230eceef0 $s7SwiftUI9ViewGraphC13updateOutputs2atyAA4TimeV_tF + 152 24 SwiftUICore 0x0000000230ec87b8 $s7SwiftUI25ViewGraphRootValueUpdaterPAAE6render8interval17updateDisplayList15targetTimestampySd_SbAA4TimeVSgtFyyXEfU + 776 25 SwiftUICore 0x0000000230ec6a84 $s7SwiftUI25ViewGraphRootValueUpdaterPAAE6render8interval17updateDisplayList15targetTimestampySd_SbAA4TimeVSgtF + 608 26 AppKit 0x0000000191a225f4 __swift_closure_destructor.11 + 16084 27 AppKit 0x000000019192ca70 __swift_memcpy0_1 + 252 28 AppKit 0x0000000190e2a9d8 -[NSApplication _terminateFromSender:askIfShouldTerminate:saveWindows:] + 66988 29 AppKit 0x0000000190b07280 +[NSAnimationContext runAnimationGroup:] + 56 30 AppKit 0x0000000191a1f230 __swift_closure_destructor.11 + 2832 31 AppKit 0x0000000191a1084c __swift__destructor.144 + 5860 32 AppKit 0x0000000191a10880 __swift__destructor.144 + 5912 33 AppKit 0x0000000191b04228 __swift__destructor.26 + 260 34 AppKit 0x0000000191b04250 __swift__destructor.26 + 300 35 AppKit 0x0000000191bb52b0 __swift_memcpy18_8 + 11648 36 AppKit 0x0000000191bb58ac __swift_memcpy18_8 + 13180 37 AppKit 0x0000000191523ab8 ___NSViewLayout_block_invoke + 644 38 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 39 AppKit 0x0000000190b364a8 _NSViewLayout + 96 40 AppKit 0x0000000191518bb4 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 380 41 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 42 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 43 AppKit 0x0000000191518cf8 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 704 44 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 45 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 46 AppKit 0x0000000191518cf8 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 704 47 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 48 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 49 AppKit 0x0000000191518cf8 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 704 50 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 51 AppKit 0x0000000190b3643c -[NSView _layoutSubtreeWithOldSize:] + 100 52 AppKit 0x0000000191519748 __56-[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:]_block_invoke + 876 53 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 54 AppKit 0x0000000190b3600c -[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 100 55 AppKit 0x0000000190b31b5c NSPerformVisuallyAtomicChange + 128 56 AppKit 0x0000000190b35f9c -[NSView layoutSubtreeIfNeeded] + 96 57 AppKit 0x0000000191830754 -[NSWindow(NSConstraintBasedLayoutInternal) _layoutViewTree] + 108 58 AppKit 0x0000000191830950 -[NSWindow(NSConstraintBasedLayoutInternal) layoutIfNeeded] + 240 59 AppKit 0x0000000190b95ca8 __NSWindowGetDisplayCycleObserverForLayout_block_invoke + 364 60 AppKit 0x0000000190b951d8 NSDisplayCycleObserverInvoke + 152 61 AppKit 0x0000000190b94e64 NSDisplayCycleFlush + 656 62 QuartzCore 0x0000000196bc108c _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 120 63 QuartzCore 0x0000000196bbf68c _ZN2CA11Transaction6commitEv + 324 64 QuartzCore 0x0000000196bbf370 _ZN2CA11Transaction5flushEv + 84 65 AppKit 0x0000000190d1a258 _NSTryRunModal + 60 66 AppKit 0x0000000190d872d4 -[NSAlert runModal] + 196 67 libqcocoa.dylib 0x0000000113abb0e8 qt_plugin_instan libc++abi: terminating due to uncaught exception of type NSException zsh: abortThanks.
@Qoissi The stack trace is very likely from
QMessageBox, yes -NSAlertis the native AppKit component for message boxes.The crash is eventually an Objective-C exception being thrown, related to a vector image being zero sized. The trace passing from AppKit to SwiftUI is unusual, probably an internal change Apple did for macOS 27.
It is hard to tell the exact reason without a debugger attached. If you want to try something cheap, you can try to explicitly set an icon on the message box to see if it prevents the crash.
Googling for
CUINamedVectorGlyphcomes up with many issues related to crashes across multiple projects. See if any sounds like your situation.