Open qu1ck opened 1 month ago
Thanks for the detailed report.
We have a theory about what's going on, i'll update this ticket in the next few days hopefully.
Unfortunately my theory didn't work.
One thing to point out, is that the crash log has many threads, but PyMuPDF does not support use by multiple threads. Is this likely to be a problem here?
There are many threads because it's a gui cpp application, but only the main thread is running python interpreter so that should not be an issue.
Description of the bug
Not sure if this should be reported in mupdf repo instead, please let me know.
How to reproduce the bug
The trigger for this crash is somewhat convoluted. KiCad EDA package uses python scripting for it's plugins and this was discovered when one plugin is launched while another plugin that uses pymupdf is present in the installation. Original bug report is here: https://github.com/openscopeproject/InteractiveHtmlBom/issues/467
After looking at the crash it's apparent that none of the plugins have anything to do with the crash, it happens when python garbage collects some objects and in particular FzColorSpace causes the crash.
Full crash log
``` ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Process: kicad [1099] Path: /Applications/KiCad/KiCad.app/Contents/MacOS/kicad Identifier: org.kicad.kicad Version: 8.0.5 (8.0.5) Code Type: X86-64 (Native) Parent Process: launchd [1] User ID: 501 Date/Time: 2024-09-17 02:59:30.5148 -0700 OS Version: macOS 12.6.5 (21G531) Report Version: 12 Anonymous UUID: 3E9CA79D-3423-4873-976A-2EA9582F85BB Time Awake Since Boot: 890 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 0x0000000000000030 Exception Codes: 0x0000000000000001, 0x0000000000000030 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [1099] VM Region Info: 0x30 is not in any region. Bytes before following region: 140737487368144 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> VM_ALLOCATE 7ffffff0f000-7ffffff10000 [ 4K] r-x/r-x SM=ALI Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libmupdf.dylib 0x120629430 fz_drop_icc_profile + 16 1 libmupdf.dylib 0x12062bf58 fz_drop_colorspace_imp + 136 2 libmupdfcpp.so 0x11e6dcdad mupdf::ll_fz_drop_colorspace(fz_colorspace*) + 61 3 libmupdfcpp.so 0x11e69d3bc mupdf::FzColorspace::~FzColorspace() + 12 4 _mupdf.so 0x1221183a6 _wrap_delete_FzColorspace(_object*, _object*) + 70 5 _mupdf.so 0x122359c0d SwigPyObject_dealloc(_object*) + 205 6 Python 0x103bc610e dict_dealloc + 142 7 Python 0x103be7d72 subtype_dealloc + 1106 8 Python 0x103bc610e dict_dealloc + 142 9 Python 0x103be7d72 subtype_dealloc + 1106 10 Python 0x103bc37d1 PyDict_Clear + 465 11 Python 0x103bc67e9 dict_tp_clear + 9 12 Python 0x103ce2e8d collect + 3245 13 Python 0x103ce21c8 _PyGC_CollectNoFail + 72 14 Python 0x103ca5aeb _PyImport_Cleanup + 3483 15 Python 0x103cbca40 Py_FinalizeEx + 160 16 kicad 0x100614ad0 pybind11::finalize_interpreter() + 704 17 kicad 0x1006146fd SCRIPTING::~SCRIPTING() + 29 18 kicad 0x10047da3f PGM_BASE::~PGM_BASE() + 335 19 libsystem_c.dylib 0x7ff808d44de4 __cxa_finalize_ranges + 409 20 libsystem_c.dylib 0x7ff808d44bfe exit + 35 21 libdyld.dylib 0x7ff808e58375 dyld4::LibSystemHelpers::exit(int) const + 11 22 dyld 0x10246e558 start + 504 Thread 1: 0 libsystem_pthread.dylib 0x7ff808e47f48 start_wqthread + 0 Thread 2:: com.apple.NSEventThread 0 libsystem_kernel.dylib 0x7ff808e0f96a mach_msg_trap + 10 1 libsystem_kernel.dylib 0x7ff808e0fcd8 mach_msg + 56 2 CoreFoundation 0x7ff808f16510 __CFRunLoopServiceMachPort + 319 3 CoreFoundation 0x7ff808f14ba0 __CFRunLoopRun + 1276 4 CoreFoundation 0x7ff808f13fe4 CFRunLoopRunSpecific + 562 5 AppKit 0x7ff80b9f298e _NSEventThread + 132 6 libsystem_pthread.dylib 0x7ff808e4c4e1 _pthread_start + 125 7 libsystem_pthread.dylib 0x7ff808e47f6b thread_start + 15 Thread 3:: com.apple.CFSocket.private 0 libsystem_kernel.dylib 0x7ff808e17d4a __select + 10 1 CoreFoundation 0x7ff808f3d2bb __CFSocketManager + 643 2 libsystem_pthread.dylib 0x7ff808e4c4e1 _pthread_start + 125 3 libsystem_pthread.dylib 0x7ff808e47f6b thread_start + 15 Thread 4: 0 libsystem_kernel.dylib 0x7ff808e123da __psynch_cvwait + 10 1 libsystem_pthread.dylib 0x7ff808e4ca6f _pthread_cond_wait + 1249 2 libc++.1.dylib 0x7ff808daad22 std::__1::condition_variable::wait(std::__1::unique_lockBy bisecting the pymupdf version I found that last one that does not crash is 1.23.8. Crash reproduces reliably.
PyMuPDF version
1.24.10
Operating system
MacOS
Python version
3.9