The Wayback Machine - https://web.archive.org/web/20250601023645/https://github.com/python/cpython/issues/102525
Skip to content

Crash (SIGTRAP) with turtle (tkinter) and os.fork() #102525

Closed as not planned
Closed as not planned
@impact27

Description

@impact27

Bug report

This might be a mac M1 issue (spyder-ide/spyder#20629 (comment))

If I import turtle, os.fork()start to crash. To reproduce:

1 - create a file containing

import turtle
import os
import subprocess as sp

pid = os.fork()
if pid == 0:
    try:
        print("child")
        p = sp.run(["pwd"]) # SIGTRAP
    finally:
        os._exit(0)
else:
    print("parent")

2 - run with python3 test.py
3 - see a crash:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Python [1049]
Path:                  /opt/homebrew/*/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
Identifier:            org.python.python
Version:               3.10.8 (3.10.8)
Code Type:             ARM-64 (Native)
Parent Process:        Python [1048]
Responsible:           Terminal [595]
User ID:               503

Date/Time:             2023-03-08 08:34:09.3847 +0100
OS Version:            macOS 13.1 (22C65)
Report Version:        12
Anonymous UUID:        19A97DBC-B230-3072-1DD4-BC71816B8701


Time Awake Since Boot: 46 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x00000001933ee0e0

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [1049]

Application Specific Information:
*** single-threaded process forked ***
BUG IN CLIENT OF LIBPLATFORM: os_unfair_lock is corrupt
Abort Cause 258
crashed on child side of fork pre-exec


Kernel Triage:
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_platform.dylib      	       0x1933ee0e0 _os_unfair_lock_corruption_abort + 88
1   libsystem_platform.dylib      	       0x1933e9024 _os_unfair_lock_lock_slow + 328
2   libtcl8.6.dylib               	       0x104d79f24 AtForkPrepare + 44
3   libsystem_pthread.dylib       	       0x1933bc744 _pthread_atfork_prepare_handlers + 96
4   libSystem.B.dylib             	       0x19ea5551c libSystem_atfork_prepare + 32
5   libsystem_c.dylib             	       0x1932a3a28 fork + 36
6   _posixsubprocess.cpython-310-darwin.so	       0x104c26e28 do_fork_exec + 68
7   _posixsubprocess.cpython-310-darwin.so	       0x104c26944 subprocess_fork_exec + 796
8   Python                        	       0x104742498 cfunction_call + 96
9   Python                        	       0x1046f1290 _PyObject_MakeTpCall + 136
10  Python                        	       0x1047eaf0c call_function + 272
11  Python                        	       0x1047e8694 _PyEval_EvalFrameDefault + 42888
12  Python                        	       0x1047dccac _PyEval_Vector + 376
13  Python                        	       0x1047eae7c call_function + 128
14  Python                        	       0x1047e861c _PyEval_EvalFrameDefault + 42768
15  Python                        	       0x1047dccac _PyEval_Vector + 376
16  Python                        	       0x1046f14f8 _PyObject_FastCallDictTstate + 96
17  Python                        	       0x104766ea8 slot_tp_init + 196
18  Python                        	       0x10475ee60 type_call + 288
19  Python                        	       0x1046f1cb0 _PyObject_Call + 128
20  Python                        	       0x1047e885c _PyEval_EvalFrameDefault + 43344
21  Python                        	       0x1047dccac _PyEval_Vector + 376
22  Python                        	       0x1047eae7c call_function + 128
23  Python                        	       0x1047e8694 _PyEval_EvalFrameDefault + 42888
24  Python                        	       0x1047dccac _PyEval_Vector + 376
25  Python                        	       0x1047dcb20 PyEval_EvalCode + 104
26  Python                        	       0x104837354 run_eval_code_obj + 84
27  Python                        	       0x1048372b8 run_mod + 112
28  Python                        	       0x104836f4c pyrun_file + 148
29  Python                        	       0x104836880 _PyRun_SimpleFileObject + 268
30  Python                        	       0x104835ec4 _PyRun_AnyFileObject + 232
31  Python                        	       0x104858f14 pymain_run_file_obj + 220
32  Python                        	       0x104858664 pymain_run_file + 72
33  Python                        	       0x104857ef4 Py_RunMain + 872
34  Python                        	       0x1048592f0 Py_BytesMain + 40
35  dyld                          	       0x193093e50 start + 2544


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000102   x1: 0x0000000000000000   x2: 0x0000000000000102   x3: 0x0000000000000000
    x4: 0x00000001f0145b48   x5: 0x00000000ffffffff   x6: 0x00000000ffffffff   x7: 0x00000000ffffffff
    x8: 0x0000000000000102   x9: 0x00000000ffffff02  x10: 0x000000000003fe00  x11: 0x0000000000000005
   x12: 0x0000000000000006  x13: 0x0000000000000001  x14: 0x0000000000000001  x15: 0x0000000000000000
   x16: 0x0000000000000203  x17: 0x00000001f3564890  x18: 0x0000000000000000  x19: 0x0000000000000303
   x20: 0x0000000104dad040  x21: 0x0000000001000002  x22: 0x0000000000000102  x23: 0x0000000000000000
   x24: 0x0000000000000000  x25: 0x0000000000000303  x26: 0x00000001045c59b0  x27: 0x0000000000000000
   x28: 0x0000000104993608   fp: 0x000000016bb79de0   lr: 0x00000001933e9024
    sp: 0x000000016bb79da0   pc: 0x00000001933ee0e0 cpsr: 0xa0001000
   far: 0x00000001ec2140b8  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x1933e7000 -        0x1933eeffb libsystem_platform.dylib (*) <b215ae90-4ed2-3fcd-8ccc-6c0d93cc4f41> /usr/lib/system/libsystem_platform.dylib
       0x104c70000 -        0x104d9bfff libtcl8.6.dylib (*) <6912728a-6463-3968-90ae-095b82fd3fdd> /opt/homebrew/*/libtcl8.6.dylib
       0x1933b6000 -        0x1933c2ffb libsystem_pthread.dylib (*) <132084c6-c347-3489-9ac2-fcaad21cdb73> /usr/lib/system/libsystem_pthread.dylib
       0x19ea54000 -        0x19ea55fff libSystem.B.dylib (*) <8d5887c4-4ee2-3b8c-8533-255448018ffe> /usr/lib/libSystem.B.dylib
       0x19327d000 -        0x1932fdff3 libsystem_c.dylib (*) <756cd0d2-3241-3a74-8c59-02632dcee221> /usr/lib/system/libsystem_c.dylib
       0x104c24000 -        0x104c27fff _posixsubprocess.cpython-310-darwin.so (*) <95127bc4-3c14-398d-8b6d-782105c405c6> /opt/homebrew/*/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so
       0x104688000 -        0x10495bfff org.python.python (3.10.8, (c) 2001-2021 Python Software Foundation.) <f2371089-60d8-3b91-a475-4f4dcb3b84e3> /opt/homebrew/*/Python.framework/Versions/3.10/Python
       0x19308e000 -        0x193118b63 dyld (*) <487cfdeb-9b07-39bf-bfb9-970b61aea2d1> /usr/lib/dyld

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=972.5M resident=0K(0%) swapped_out_or_unallocated=972.5M(100%)
Writable regions: Total=816.2M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=816.2M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                   32K        1 
MALLOC                           171.2M       17 
MALLOC guard page                   96K        5 
MALLOC_MEDIUM (reserved)         240.0M        2         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                         16K        1 
Stack                             16.0M        1 
VM_ALLOCATE                       5120K        5 
__AUTH                             572K      132 
__AUTH_CONST                      10.3M      275 
__DATA                            2835K      271 
__DATA_CONST                      13.7M      286 
__DATA_DIRTY                       678K       97 
__FONT_DATA                        2352        1 
__LINKEDIT                       767.8M       11 
__OBJC_CONST                      1161K      107 
__OBJC_RO                         65.4M        1 
__OBJC_RW                         1986K        1 
__TEXT                           204.7M      301 
dyld private memory                256K        1 
shared memory                       32K        2 
===========                     =======  ======= 
TOTAL                              1.8G     1519 
TOTAL, minus reserved VM space     1.2G     1519 

Your environment

  • CPython versions tested on: Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin

  • Operating system and architecture: Apple M1 Max 13.1 (22C65)

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-macstdlibPython modules in the Lib dirtype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions