mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.69k stars 1.31k forks source link

BUG: Brain from pyvistaqt breaks when opened from running QApplication instance on macOS #10659

Closed marsipu closed 1 year ago

marsipu commented 2 years ago

Describe the bug

When an instance of mne.viz.Brain is shown from within an already running instance of QApplication, the python interpreter crashes with a SegmentationError. This happens only on macOS.

Steps to reproduce

import sys

import mne
from PyQt5.QtWidgets import QMainWindow, QWidget, QVBoxLayout, QPushButton, \
    QApplication

mne.datasets.fetch_fsaverage()

def plot_brain():
    with mne.viz.use_3d_backend('pyvistaqt'):
        Brain = mne.viz.get_brain_class()
        brain = Brain('fsaverage')

class TestWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        widget = QWidget()
        layout = QVBoxLayout(widget)
        test_bt = QPushButton('Plot Brain')
        test_bt.clicked.connect(plot_brain)
        layout.addWidget(test_bt)
        self.setCentralWidget(widget)

def main():
    app = QApplication.instance()
    if app is None:
        app = QApplication(sys.argv)
    window = TestWindow()
    window.show()
    app.exec()

if __name__ == '__main__':
    main()

Expected results

Brain is shown and the already running QApplication works with pyvistaqt.

Actual results

Somehow interacting with the opened Brain-Window (moving the mouse) causes a SegmentationError and breaks the python interpreter.

SegmentationError ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Process: python3.10 [1841] Path: /Users/USER/*/python Identifier: python3.10 Version: ??? Code Type: X86-64 (Native) Parent Process: zsh [1815] Responsible: Terminal [1812] User ID: 501 Date/Time: 2022-05-20 20:44:28.4389 +0200 OS Version: macOS 12.3.1 (21E258) Report Version: 12 Anonymous UUID: BF4802CD-9CFE-42B1-859F-25CDBA0EE5BD Time Awake Since Boot: 1300 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000000006b6f64 Exception Codes: 0x0000000000000001, 0x00000000006b6f64 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [1841] VM Region Info: 0x6b6f64 is not in any region. Bytes before following region: 4412035228 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 10765c000-1079d0000 [ 3536K] r-x/r-x SM=COW .../*/python3.10 Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 ??? 0x6b6f64 ??? 1 libvtkRenderingOpenGL2-9.1.9.1.0.dylib 0x16e487bb9 -[vtkCocoaGLView modifyDPIForBackingScaleFactorOfWindow:] + 249 2 libvtkRenderingOpenGL2-9.1.9.1.0.dylib 0x16e487c31 -[vtkCocoaGLView viewWillMoveToWindow:] + 81 3 AppKit 0x7ff811b1740a -[NSView _setWindow:] + 277 4 AppKit 0x7ff812367864 __21-[NSView _setWindow:]_block_invoke.425 + 299 5 AppKit 0x7ff811b17a74 -[NSView _setWindow:] + 1919 6 AppKit 0x7ff811d6d6f2 -[NSWindow dealloc] + 882 7 libobjc.A.dylib 0x7ff80eeaf14a AutoreleasePoolPage::releaseUntil(objc_object**) + 164 8 libobjc.A.dylib 0x7ff80eeabf8f objc_autoreleasePoolPop + 168 9 AppKit 0x7ff811aff6fd -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4213 10 AppKit 0x7ff811af12a9 -[NSApplication run] + 586 Thread 1: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 libomp.dylib 0x1081097ab void __kmp_suspend_64(int, kmp_flag_64*) + 299 3 libomp.dylib 0x1080eb587 kmp_flag_64::wait(kmp_info*, int, void*) + 1639 4 libomp.dylib 0x1080e731c __kmp_hyper_barrier_release(barrier_type, kmp_info*, int, int, int, void*) + 172 5 libomp.dylib 0x1080eab5f __kmp_fork_barrier(int, int) + 447 6 libomp.dylib 0x1080c53aa __kmp_launch_thread + 330 7 libomp.dylib 0x108107fda __kmp_launch_worker(void*) + 330 8 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 9 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 2: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 libomp.dylib 0x1081097ab void __kmp_suspend_64(int, kmp_flag_64*) + 299 3 libomp.dylib 0x1080eb587 kmp_flag_64::wait(kmp_info*, int, void*) + 1639 4 libomp.dylib 0x1080e731c __kmp_hyper_barrier_release(barrier_type, kmp_info*, int, int, int, void*) + 172 5 libomp.dylib 0x1080eab5f __kmp_fork_barrier(int, int) + 447 6 libomp.dylib 0x1080c53aa __kmp_launch_thread + 330 7 libomp.dylib 0x108107fda __kmp_launch_worker(void*) + 330 8 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 9 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 3: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 4: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 5: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 6:: com.apple.NSEventThread 0 libsystem_kernel.dylib 0x7ff80efd897a mach_msg_trap + 10 1 libsystem_kernel.dylib 0x7ff80efd8ce8 mach_msg + 56 2 CoreFoundation 0x7ff80f0dbcdd __CFRunLoopServiceMachPort + 319 3 CoreFoundation 0x7ff80f0da368 __CFRunLoopRun + 1276 4 CoreFoundation 0x7ff80f0d97ac CFRunLoopRunSpecific + 562 5 AppKit 0x7ff811c6df5e _NSEventThread + 132 6 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 7 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 7: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 8: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 9: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 10: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 11: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 12: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 13: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 14: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 15: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 16: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 17: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 18: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 interpreter.cpython-310-darwin.so 0x16d8a5f73 th_worker(void*) + 163 3 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 4 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 19: 0 libsystem_pthread.dylib 0x7ff80f010f48 start_wqthread + 0 Thread 20: 0 libsystem_kernel.dylib 0x7ff80efdb3ea __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff80f015a6f _pthread_cond_wait + 1249 2 libomp.dylib 0x1081097ab void __kmp_suspend_64(int, kmp_flag_64*) + 299 3 libomp.dylib 0x1080eb587 kmp_flag_64::wait(kmp_info*, int, void*) + 1639 4 libomp.dylib 0x1080e731c __kmp_hyper_barrier_release(barrier_type, kmp_info*, int, int, int, void*) + 172 5 libomp.dylib 0x1080eab5f __kmp_fork_barrier(int, int) + 447 6 libomp.dylib 0x1080c53aa __kmp_launch_thread + 330 7 libomp.dylib 0x108107fda __kmp_launch_worker(void*) + 330 8 libsystem_pthread.dylib 0x7ff80f0154e1 _pthread_start + 125 9 libsystem_pthread.dylib 0x7ff80f010f6b thread_start + 15 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000000000048 rbx: 0x00007fc94e0d6a50 rcx: 0x0000000174277330 rdx: 0x0000000000000048 rdi: 0x00007fc94e0d6a50 rsi: 0x0000000000000048 rbp: 0x00007ff7b88a2460 rsp: 0x00007ff7b88a23c8 r8: 0x00007fc94873e260 r9: 0x0000000000000080 r10: 0x000000016e60f692 r11: 0x000000016e486c90 r12: 0x00007fc94abb59d8 r13: 0x00007fc94abb5940 r14: 0x0000000000000000 r15: 0x00007ff8297d0b30 rip: 0x00000000006b6f64 rfl: 0x0000000000010206 cr2: 0x00000000006b6f64 Logical CPU: 2 Error Code: 0x00000014 (no mapping for user instruction read) Trap Number: 14 Binary Images: 0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ??? 0x16e477000 - 0x16e5fafff libvtkRenderingOpenGL2-9.1.9.1.0.dylib (*) /Users/USER/*/libvtkRenderingOpenGL2-9.1.9.1.0.dylib 0x7ff811ac2000 - 0x7ff81294ffff com.apple.AppKit (6.9) <92a78ebd-bba5-3f18-a5e1-768c955539d7> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 0x7ff80ee9e000 - 0x7ff80eedbfff libobjc.A.dylib (*) <6d51b7b2-136e-336d-95ca-442af1009ec2> /usr/lib/libobjc.A.dylib 0x7ff80efd7000 - 0x7ff80f00efff libsystem_kernel.dylib (*) <26a59789-b846-3ed4-96dc-8dbef3c0c8e7> /usr/lib/system/libsystem_kernel.dylib 0x7ff80f00f000 - 0x7ff80f01afff libsystem_pthread.dylib (*) <2f6c275d-7e14-3d31-a924-e1bb41d2415f> /usr/lib/system/libsystem_pthread.dylib 0x1080a3000 - 0x10812cfff libomp.dylib (*) <74118088-4ab0-37ef-a426-17e69b3ccc73> /Users/USER/*/libomp.dylib 0x7ff80f05c000 - 0x7ff80f55dfff com.apple.CoreFoundation (6.9) <743f0cb7-e962-3e42-8653-7bd141129561> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x16d88b000 - 0x16d8aafff interpreter.cpython-310-darwin.so (*) /Users/USER/*/interpreter.cpython-310-darwin.so External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 0 thread_create: 0 thread_set_state: 0 VM Region Summary: ReadOnly portion of Libraries: Total=1.3G resident=0K(0%) swapped_out_or_unallocated=1.3G(100%) Writable regions: Total=2.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=2.1G(100%) VIRTUAL REGION REGION TYPE SIZE COUNT (non-coalesced) =========== ======= ======= Accelerate framework 640K 5 Activity Tracing 256K 1 CG backing stores 640K 4 CG image 92K 5 ColorSync 240K 27 CoreAnimation 72K 14 CoreGraphics 12K 2 CoreUI image data 604K 10 Foundation 16K 1 Kernel Alloc Once 8K 1 MALLOC 403.0M 151 MALLOC guard page 32K 8 MALLOC_LARGE (reserved) 256K 2 reserved VM address space (unallocated) MALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated) OpenGL GLSL 256K 3 STACK GUARD 84K 21 Stack 48.7M 21 VM_ALLOCATE 615.5M 121 VM_ALLOCATE (reserved) 640.0M 2 reserved VM address space (unallocated) __DATA 51.5M 876 __DATA_CONST 13.8M 183 __DATA_DIRTY 541K 99 __FONT_DATA 4K 1 __GLSLBUILTINS 5176K 1 __LINKEDIT 726.8M 476 __OBJC_RO 82.6M 1 __OBJC_RW 3200K 2 __TEXT 628.9M 790 __UNICODE 592K 1 dyld private memory 1184K 3 mapped file 78.4M 23 shared memory 792K 20 =========== ======= ======= TOTAL 3.6G 2876 TOTAL, minus reserved VM space 2.6G 2876 ----------- Full Report ----------- {"app_name":"python3.10","timestamp":"2022-05-20 20:44:47.00 +0200","app_version":"","slice_uuid":"56205f92-86d4-31ea-b3c7-d87180219127","build_version":"","platform":1,"share_with_app_devs":0,"is_first_party":1,"bug_type":"309","os_version":"macOS 12.3.1 (21E258)","incident_id":"ED7460F8-BA49-46FE-B111-2A820F03AF18","name":"python3.10"} { "uptime" : 1300, "procLaunch" : "2022-05-20 20:44:17.0209 +0200", "procRole" : "Foreground", "version" : 2, "userID" : 501, "deployVersion" : 210, "modelCode" : "Macmini8,1", "procStartAbsTime" : 1296530170924, "coalitionID" : 3067, "osVersion" : { "train" : "macOS 12.3.1", "build" : "21E258", "releaseType" : "User" }, "captureTime" : "2022-05-20 20:44:28.4389 +0200", "incident" : "ED7460F8-BA49-46FE-B111-2A820F03AF18", "bug_type" : "309", "pid" : 1841, "procExitAbsTime" : 1307946582372, "cpuType" : "X86-64", "procName" : "python3.10", "procPath" : "\/Users\/USER\/*\/python", "parentProc" : "zsh", "parentPid" : 1815, "coalitionName" : "com.apple.Terminal", "crashReporterKey" : "BF4802CD-9CFE-42B1-859F-25CDBA0EE5BD", "responsiblePid" : 1812, "responsibleProc" : "Terminal", "sip" : "enabled", "vmRegionInfo" : "0x6b6f64 is not in any region. Bytes before following region: 4412035228\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n __TEXT 10765c000-1079d0000 [ 3536K] r-x\/r-x SM=COW ...\/*\/python3.10", "isCorpse" : 1, "exception" : {"codes":"0x0000000000000001, 0x00000000006b6f64","rawCodes":[1,7040868],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x00000000006b6f64"}, "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":1841}, "vmregioninfo" : "0x6b6f64 is not in any region. Bytes before following region: 4412035228\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n __TEXT 10765c000-1079d0000 [ 3536K] r-x\/r-x SM=COW ...\/*\/python3.10", "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0}, "faultingThread" : 0, "threads" : [{"triggered":true,"id":19930,"threadState":{"r13":{"value":140502518946112},"rax":{"value":72},"rflags":{"value":66054},"cpu":{"value":2},"r14":{"value":0},"rsi":{"value":72},"r8":{"value":140502480708192},"cr2":{"value":7040868},"rdx":{"value":72},"r10":{"value":6146815634,"symbolLocation":2,"symbol":"OBJC_CLASS_$_vtkCocoaGLView"},"r9":{"value":128},"r15":{"value":140703824677680,"objc-selector":"viewWillMoveToWindow:"},"rbx":{"value":140502574656080},"trap":{"value":14,"description":"(no mapping for user instruction read)"},"err":{"value":20},"r11":{"value":6145207440,"symbolLocation":0,"symbol":"-[vtkCocoaGLView getVTKRenderWindow]"},"rip":{"value":7040868,"matchesCrashFrame":1},"rbp":{"value":140701929710688},"rsp":{"value":140701929710536},"r12":{"value":140502518946264},"rcx":{"value":6243709744},"flavor":"x86_THREAD_STATE","rdi":{"value":140502574656080}},"queue":"com.apple.main-thread","frames":[{"imageOffset":7040868,"imageIndex":0},{"imageOffset":68537,"symbol":"-[vtkCocoaGLView modifyDPIForBackingScaleFactorOfWindow:]","symbolLocation":249,"imageIndex":1},{"imageOffset":68657,"symbol":"-[vtkCocoaGLView viewWillMoveToWindow:]","symbolLocation":81,"imageIndex":1},{"imageOffset":349194,"symbol":"-[NSView _setWindow:]","symbolLocation":277,"imageIndex":2},{"imageOffset":9066596,"symbol":"__21-[NSView _setWindow:]_block_invoke.425","symbolLocation":299,"imageIndex":2},{"imageOffset":350836,"symbol":"-[NSView _setWindow:]","symbolLocation":1919,"imageIndex":2},{"imageOffset":2799346,"symbol":"-[NSWindow dealloc]","symbolLocation":882,"imageIndex":2},{"imageOffset":69962,"symbol":"AutoreleasePoolPage::releaseUntil(objc_object**)","symbolLocation":164,"imageIndex":3},{"imageOffset":57231,"symbol":"objc_autoreleasePoolPop","symbolLocation":168,"imageIndex":3},{"imageOffset":251645,"symbol":"-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]","symbolLocation":4213,"imageIndex":2},{"imageOffset":193193,"symbol":"-[NSApplication run]","symbolLocation":586,"imageIndex":2}]},{"id":19933,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":419755,"symbol":"void __kmp_suspend_64(int, kmp_flag_64*)","symbolLocation":299,"imageIndex":6},{"imageOffset":296327,"symbol":"kmp_flag_64::wait(kmp_info*, int, void*)","symbolLocation":1639,"imageIndex":6},{"imageOffset":279324,"symbol":"__kmp_hyper_barrier_release(barrier_type, kmp_info*, int, int, int, void*)","symbolLocation":172,"imageIndex":6},{"imageOffset":293727,"symbol":"__kmp_fork_barrier(int, int)","symbolLocation":447,"imageIndex":6},{"imageOffset":140202,"symbol":"__kmp_launch_thread","symbolLocation":330,"imageIndex":6},{"imageOffset":413658,"symbol":"__kmp_launch_worker(void*)","symbolLocation":330,"imageIndex":6},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":19934,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":419755,"symbol":"void __kmp_suspend_64(int, kmp_flag_64*)","symbolLocation":299,"imageIndex":6},{"imageOffset":296327,"symbol":"kmp_flag_64::wait(kmp_info*, int, void*)","symbolLocation":1639,"imageIndex":6},{"imageOffset":279324,"symbol":"__kmp_hyper_barrier_release(barrier_type, kmp_info*, int, int, int, void*)","symbolLocation":172,"imageIndex":6},{"imageOffset":293727,"symbol":"__kmp_fork_barrier(int, int)","symbolLocation":447,"imageIndex":6},{"imageOffset":140202,"symbol":"__kmp_launch_thread","symbolLocation":330,"imageIndex":6},{"imageOffset":413658,"symbol":"__kmp_launch_worker(void*)","symbolLocation":330,"imageIndex":6},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":19938,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":19939,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":19981,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":20001,"name":"com.apple.NSEventThread","frames":[{"imageOffset":6522,"symbol":"mach_msg_trap","symbolLocation":10,"imageIndex":4},{"imageOffset":7400,"symbol":"mach_msg","symbolLocation":56,"imageIndex":4},{"imageOffset":523485,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":319,"imageIndex":7},{"imageOffset":516968,"symbol":"__CFRunLoopRun","symbolLocation":1276,"imageIndex":7},{"imageOffset":513964,"symbol":"CFRunLoopRunSpecific","symbolLocation":562,"imageIndex":7},{"imageOffset":1752926,"symbol":"_NSEventThread","symbolLocation":132,"imageIndex":2},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20009,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":20013,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":20014,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":20015,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":20023,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20024,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20025,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20026,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20027,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20028,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20029,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20030,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":110451,"symbol":"th_worker(void*)","symbolLocation":163,"imageIndex":8},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]},{"id":20035,"frames":[{"imageOffset":8008,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":20086,"frames":[{"imageOffset":17386,"symbol":"__psynch_cvwait","symbolLocation":10,"imageIndex":4},{"imageOffset":27247,"symbol":"_pthread_cond_wait","symbolLocation":1249,"imageIndex":5},{"imageOffset":419755,"symbol":"void __kmp_suspend_64(int, kmp_flag_64*)","symbolLocation":299,"imageIndex":6},{"imageOffset":296327,"symbol":"kmp_flag_64::wait(kmp_info*, int, void*)","symbolLocation":1639,"imageIndex":6},{"imageOffset":279324,"symbol":"__kmp_hyper_barrier_release(barrier_type, kmp_info*, int, int, int, void*)","symbolLocation":172,"imageIndex":6},{"imageOffset":293727,"symbol":"__kmp_fork_barrier(int, int)","symbolLocation":447,"imageIndex":6},{"imageOffset":140202,"symbol":"__kmp_launch_thread","symbolLocation":330,"imageIndex":6},{"imageOffset":413658,"symbol":"__kmp_launch_worker(void*)","symbolLocation":330,"imageIndex":6},{"imageOffset":25825,"symbol":"_pthread_start","symbolLocation":125,"imageIndex":5},{"imageOffset":8043,"symbol":"thread_start","symbolLocation":15,"imageIndex":5}]}], "usedImages" : [ { "size" : 0, "source" : "A", "base" : 0, "uuid" : "00000000-0000-0000-0000-000000000000" }, { "source" : "P", "arch" : "x86_64", "base" : 6145142784, "size" : 1589248, "uuid" : "e1989b46-4810-37cc-b1a6-c824b9a3a357", "path" : "\/Users\/USER\/*\/libvtkRenderingOpenGL2-9.1.9.1.0.dylib", "name" : "libvtkRenderingOpenGL2-9.1.9.1.0.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 140703425110016, "CFBundleShortVersionString" : "6.9", "CFBundleIdentifier" : "com.apple.AppKit", "size" : 15261696, "uuid" : "92a78ebd-bba5-3f18-a5e1-768c955539d7", "path" : "\/System\/Library\/Frameworks\/AppKit.framework\/Versions\/C\/AppKit", "name" : "AppKit", "CFBundleVersion" : "2113.40.127" }, { "source" : "P", "arch" : "x86_64h", "base" : 140703378825216, "size" : 253952, "uuid" : "6d51b7b2-136e-336d-95ca-442af1009ec2", "path" : "\/usr\/lib\/libobjc.A.dylib", "name" : "libobjc.A.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 140703380107264, "size" : 229376, "uuid" : "26a59789-b846-3ed4-96dc-8dbef3c0c8e7", "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib", "name" : "libsystem_kernel.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 140703380336640, "size" : 49152, "uuid" : "2f6c275d-7e14-3d31-a924-e1bb41d2415f", "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib", "name" : "libsystem_pthread.dylib" }, { "source" : "P", "arch" : "x86_64", "base" : 4429852672, "size" : 565248, "uuid" : "74118088-4ab0-37ef-a426-17e69b3ccc73", "path" : "\/Users\/USER\/*\/libomp.dylib", "name" : "libomp.dylib" }, { "source" : "P", "arch" : "x86_64h", "base" : 140703380652032, "CFBundleShortVersionString" : "6.9", "CFBundleIdentifier" : "com.apple.CoreFoundation", "size" : 5251072, "uuid" : "743f0cb7-e962-3e42-8653-7bd141129561", "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation", "name" : "CoreFoundation", "CFBundleVersion" : "1858.112" }, { "source" : "P", "arch" : "x86_64", "base" : 6132641792, "size" : 131072, "uuid" : "dd854828-7511-3db5-89d1-11d00c2e980a", "path" : "\/Users\/USER\/*\/interpreter.cpython-310-darwin.so", "name" : "interpreter.cpython-310-darwin.so" } ], "sharedCache" : { "base" : 140703377063936, "size" : 15224815616, "uuid" : "6cc5ecdc-5119-37f0-9a85-4f48a50f5f78" }, "vmSummary" : "ReadOnly portion of Libraries: Total=1.3G resident=0K(0%) swapped_out_or_unallocated=1.3G(100%)\nWritable regions: Total=2.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=2.1G(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nAccelerate framework 640K 5 \nActivity Tracing 256K 1 \nCG backing stores 640K 4 \nCG image 92K 5 \nColorSync 240K 27 \nCoreAnimation 72K 14 \nCoreGraphics 12K 2 \nCoreUI image data 604K 10 \nFoundation 16K 1 \nKernel Alloc Once 8K 1 \nMALLOC 403.0M 151 \nMALLOC guard page 32K 8 \nMALLOC_LARGE (reserved) 256K 2 reserved VM address space (unallocated)\nMALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)\nOpenGL GLSL 256K 3 \nSTACK GUARD 84K 21 \nStack 48.7M 21 \nVM_ALLOCATE 615.5M 121 \nVM_ALLOCATE (reserved) 640.0M 2 reserved VM address space (unallocated)\n__DATA 51.5M 876 \n__DATA_CONST 13.8M 183 \n__DATA_DIRTY 541K 99 \n__FONT_DATA 4K 1 \n__GLSLBUILTINS 5176K 1 \n__LINKEDIT 726.8M 476 \n__OBJC_RO 82.6M 1 \n__OBJC_RW 3200K 2 \n__TEXT 628.9M 790 \n__UNICODE 592K 1 \ndyld private memory 1184K 3 \nmapped file 78.4M 23 \nshared memory 792K 20 \n=========== ======= ======= \nTOTAL 3.6G 2876 \nTOTAL, minus reserved VM space 2.6G 2876 \n", "legacyInfo" : { "threadTriggered" : { "queue" : "com.apple.main-thread" } }, "trialInfo" : { "rollouts" : [ { "rolloutId" : "60356660bbe37970735c5624", "factorPackIds" : { }, "deploymentId" : 240000027 }, { "rolloutId" : "6112e14f37f5d11121dcd519", "factorPackIds" : { "SIRI_TEXT_TO_SPEECH" : "6267122541fbd3022330c3ea" }, "deploymentId" : 240000116 } ], "experiments" : [ ] } } Model: Macmini8,1, BootROM 1731.100.130.0.0, 4 processors, Quad-Core Intel Core i7, 2,71 GHz, 16 GB, SMC Graphics: Intel Iris Plus Graphics 655, Intel Iris Plus Graphics 655, Built-In Display: W2286, 1680 x 1050 (Widescreen Super eXtended Graphics Array Plus), Main, MirrorOff, Online Memory Module: Memory Channel A/SODIMM1, 8 GB, DDR4, 2400 MHz, Kingston, KHX2400C14S4/8G Memory Module: Memory Channel B/SODIMM2, 8 GB, DDR4, 2400 MHz, Kingston, KHX2400C14S4/8G AirPort: spairport_wireless_card_type_wifi (0x8086, 0x34), itlwm: 2.2.0 fw: 34.3125811985.0 AirPort: AirPort: Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports Network Service: Wi-Fi, AirPort, en1 PCI Card: Cannon Point-LP High Definition Audio Controller, Audio device, Internal@0,31,3 Serial ATA Device: TOSHIBA THNSNK256GVN8, 256,06 GB USB Device: USB31Bus USB Device: Extreme SSD USB Device: bluetooth_device USB Device: USB Receiver Thunderbolt Bus:

Additional information

mne sys_info Platform: macOS-12.3.1-x86_64-i386-64bit Python: 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:43:32) [Clang 12.0.1 ] Executable: /Users/martinschulz/opt/anaconda3/envs/mnedev/bin/python3.1 CPU: i386: 8 cores Memory: 16.0 GB mne: 1.1.dev0 numpy: 1.21.5 {blas=NO_ATLAS_INFO, lapack=lapack} scipy: 1.8.0 matplotlib: 3.5.1 {backend=MacOSX} sklearn: 1.0.2 numba: 0.55.1 nibabel: 3.2.2 nilearn: 0.9.0 dipy: 1.5.0 cupy: Not found pandas: 1.4.2 pyvista: 0.33.3 {OpenGL 4.1 INTEL-18.5.8 via Intel(R) Iris(TM) Plus Graphics 655} pyvistaqt: 0.9.0 ipyvtklink: 0.2.2 vtk: 9.1.0 qtpy: 2.0.1 {PyQt5=5.12.3} ipympl: Not found pooch: v1.6.0 mne_bids: 0.11.dev0 mne_nirs: Not found mne_features: Not found mne_qt_browser: 0.2.7.dev0 mne_connectivity: 0.4dev0
marsipu commented 2 years ago

@GuillaumeFavelier Do you know something about this problem?

marsipu commented 2 years ago

With mne==0.24.1 this bug doesn't seem to appear

hoechenberger commented 2 years ago

I tried to reproduce and it only crashes when the window receives an event (in my case: moving the mouse cursor), like you said. This is on macOS (btw, this is the way it's supposed to be spelled ;)) 12.3.1

https://user-images.githubusercontent.com/2046265/169799833-48fc076c-6ea3-4109-a5d2-47b3b0cafd0c.mov

larsoner commented 2 years ago

I'll take a look, see if I can reproduce, and then try to fix it hopefully today

marsipu commented 2 years ago

@larsoner Thank you, I tried to get behind it but this segmentation fault is so hard to debug since it gives little clue what the problem is

larsoner commented 2 years ago

I added a import faulthandler; faulthandler.enable() but it didn't provide any additional information. I also added some debugging prints at various points in _brain, pyvista, and pyvistaqt and couldn't figure this one out. I wonder if we need a debug build of Qt where we can get a useful traceback :(

larsoner commented 2 years ago

Okay I say that.... then almost immediately look up debugging on macOS and get a bit farther:

$ lldb python
(lldb) process launch -- -u /Users/larsoner/Desktop/rep.py
...
2022-05-24 16:15:37.299227-0400 python[91919:796914] [qt.qpa.drawing] Layer-backing is always enabled.  QT_MAC_WANTS_LAYER/_q_mac_wantsLayer has no effect.
Process 91919 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x843e643d642455)
    frame #0: 0x0000000154953088 libvtkRenderingOpenGL2-9.1.9.1.0.dylib`-[vtkCocoaGLView modifyDPIForBackingScaleFactorOfWindow:] + 164
libvtkRenderingOpenGL2-9.1.9.1.0.dylib`-[vtkCocoaGLView modifyDPIForBackingScaleFactorOfWindow:]:
->  0x154953088 <+164>: ldr    x2, [x8, #0x1f0]
    0x15495308c <+168>: ldp    x29, x30, [sp, #0x20]
    0x154953090 <+172>: ldp    x20, x19, [sp, #0x10]
    0x154953094 <+176>: ldp    d9, d8, [sp], #0x30

Next up is probably to look into why the DPI modification here causes a segfault.

hoechenberger commented 2 years ago

So it's likely a VTK bug?

larsoner commented 2 years ago

Yeah, let's see what they say

https://gitlab.kitware.com/vtk/vtk/-/issues/18559

larsoner commented 1 year ago

The related VTK issue was closed a year ago and I just tried the MWE at the top and now it's fine!