You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unrecoverable stack overflow with infinite recursion on macOS #131543
In the CI of cloudpickle, we encountered a crash of the python interpreter due to a stack overflow with python3.14.0a6.
Reverting to python3.14.0a5 fixes the error.
This might be related to GH-130398, with a bad detection of the limit of the stack?
I could not test it locally as I don't own a mac.
changed the title [-]Unrecoverable stack overflow with infinite recursion on OSX[/-][+]Unrecoverable stack overflow with infinite recursion on macOS[/+]on Mar 21, 2025
I can reproduce the crash using any of the python.org macOS Python 3.14 alphas, as well as the latest python.org and MacPorts-supplied Python 3.13(.2) and 3.12(.9) - I didn't try any earlier versions of them. It might be an issue with release vs debug builds and there certainly have been many instances in the past of different stack limits on different platforms, especially on macOS.
Hello,
In the reported case, it does not happen with 3.14.0a5 on the same platform, so I don't know if it is linked to how it is built (I'm guessing both builds have a similar process).
My apologies! I somehow totally misread your report. Contrary to what I originally wrote, I cannot reproduce the failure with any of those python.org macOS installers, including 3.14.0a5 and a6. I see that the actions/python-versions repo claims to repackage the python.org installers for macOS but I have no insight into how they might do that or what differences Github CI runners might present that might be a factor here. All I can say is that we have our own Github CI jobs for both Intel and Apple Silicon (ARM). And our python.org release installers are tested on a variety of real machines and VMs of both architectures with various macOS versions but not on a Github runner itself.
FWIW: The reproducer in the initial message crashes for me with Python 3.14a6, but only for arm64 and not x86_64 (e.g. fatal error with arch -arm64 python3.14 repro.py and no issue with arch -x86_64 python3.14 repro.py). This is with the python.org installer.
I can reproduce the issue on my M3 Mac running macOS 15.5 with the script from OP and with python.org installer for 3.14.0b1.
Contrary to the comment above this one, the crash happens for me with both native arm64 mode and in x86_64 mode.
Interestingly, though, the crash does not happen with free-threaded version of 3.14.0b1 from python.org installer, nor if I manually compile 3.14.0b1 from source (but I haven't really tried to fully match the build flags, so that might be expected).
As far as I can tell, the problem is that pthread_getattr_np is not available on macOS, so the stack size is set to hard-coded value of 4 MB:
So the hard-coded stack size (Py_C_STACK_SIZE) should be raised for macOS, or even better, the actual stack size should be obtained using the macOS-specific pthread_get_stackaddr_np() and pthread_get_stacksize_np() functions.
Some additional debugging info...
For testing, I've extended the OP test script with recursion level counter and a manual stack pointer tracking:
% python3.14 repro.py
Stack address: 6163398656 = 0x16F5E0000
Stack size: 16777216 = 16384.0 kB = 16.0 MB
Stack pointer: 0x16F5D7B20, depth: 33.22 kB
Testing Recursion Limit
Recursion level: 1, stack pointer: 0x16F5D0D60, depth: 60.66 kB
Recursion level: 2, stack pointer: 0x16F5C9F70, depth: 88.14 kB
Recursion level: 3, stack pointer: 0x16F5C3180, depth: 115.62 kB
Recursion level: 4, stack pointer: 0x16F5BC390, depth: 143.11 kB
Recursion level: 5, stack pointer: 0x16F5B55A0, depth: 170.59 kB
Recursion level: 6, stack pointer: 0x16F5AE7B0, depth: 198.08 kB
Recursion level: 7, stack pointer: 0x16F5A79C0, depth: 225.56 kB
Recursion level: 8, stack pointer: 0x16F5A0BD0, depth: 253.05 kB
Recursion level: 9, stack pointer: 0x16F599DE0, depth: 280.53 kB
Recursion level: 10, stack pointer: 0x16F592FF0, depth: 308.02 kB
Recursion level: 11, stack pointer: 0x16F58C200, depth: 335.50 kB
Recursion level: 12, stack pointer: 0x16F585410, depth: 362.98 kB
Recursion level: 13, stack pointer: 0x16F57E620, depth: 390.47 kB
Recursion level: 14, stack pointer: 0x16F577830, depth: 417.95 kB
Recursion level: 15, stack pointer: 0x16F570A40, depth: 445.44 kB
Recursion level: 16, stack pointer: 0x16F569C50, depth: 472.92 kB
Recursion level: 17, stack pointer: 0x16F562E60, depth: 500.41 kB
Recursion level: 18, stack pointer: 0x16F55C070, depth: 527.89 kB
Recursion level: 19, stack pointer: 0x16F555280, depth: 555.38 kB
Recursion level: 20, stack pointer: 0x16F54E490, depth: 582.86 kB
Recursion level: 21, stack pointer: 0x16F5476A0, depth: 610.34 kB
Recursion level: 22, stack pointer: 0x16F5408B0, depth: 637.83 kB
Recursion level: 23, stack pointer: 0x16F539AC0, depth: 665.31 kB
Recursion level: 24, stack pointer: 0x16F532CD0, depth: 692.80 kB
Recursion level: 25, stack pointer: 0x16F52BEE0, depth: 720.28 kB
Recursion level: 26, stack pointer: 0x16F5250F0, depth: 747.77 kB
Recursion level: 27, stack pointer: 0x16F51E300, depth: 775.25 kB
Recursion level: 28, stack pointer: 0x16F517510, depth: 802.73 kB
Recursion level: 29, stack pointer: 0x16F510720, depth: 830.22 kB
Recursion level: 30, stack pointer: 0x16F509930, depth: 857.70 kB
Recursion level: 31, stack pointer: 0x16F502B40, depth: 885.19 kB
Recursion level: 32, stack pointer: 0x16F4FBD50, depth: 912.67 kB
Recursion level: 33, stack pointer: 0x16F4F4F60, depth: 940.16 kB
Recursion level: 34, stack pointer: 0x16F4EE170, depth: 967.64 kB
Recursion level: 35, stack pointer: 0x16F4E7380, depth: 995.12 kB
Recursion level: 36, stack pointer: 0x16F4E0590, depth: 1022.61 kB
Recursion level: 37, stack pointer: 0x16F4D97A0, depth: 1050.09 kB
Recursion level: 38, stack pointer: 0x16F4D29B0, depth: 1077.58 kB
Recursion level: 39, stack pointer: 0x16F4CBBC0, depth: 1105.06 kB
Recursion level: 40, stack pointer: 0x16F4C4DD0, depth: 1132.55 kB
Recursion level: 41, stack pointer: 0x16F4BDFE0, depth: 1160.03 kB
Recursion level: 42, stack pointer: 0x16F4B71F0, depth: 1187.52 kB
Recursion level: 43, stack pointer: 0x16F4B0400, depth: 1215.00 kB
Recursion level: 44, stack pointer: 0x16F4A9610, depth: 1242.48 kB
Recursion level: 45, stack pointer: 0x16F4A2820, depth: 1269.97 kB
Recursion level: 46, stack pointer: 0x16F49BA30, depth: 1297.45 kB
Recursion level: 47, stack pointer: 0x16F494C40, depth: 1324.94 kB
Recursion level: 48, stack pointer: 0x16F48DE50, depth: 1352.42 kB
Recursion level: 49, stack pointer: 0x16F487060, depth: 1379.91 kB
Recursion level: 50, stack pointer: 0x16F480270, depth: 1407.39 kB
Recursion level: 51, stack pointer: 0x16F479480, depth: 1434.88 kB
Recursion level: 52, stack pointer: 0x16F472690, depth: 1462.36 kB
Recursion level: 53, stack pointer: 0x16F46B8A0, depth: 1489.84 kB
Recursion level: 54, stack pointer: 0x16F464AB0, depth: 1517.33 kB
Recursion level: 55, stack pointer: 0x16F45DCC0, depth: 1544.81 kB
Recursion level: 56, stack pointer: 0x16F456ED0, depth: 1572.30 kB
Recursion level: 57, stack pointer: 0x16F4500E0, depth: 1599.78 kB
Recursion level: 58, stack pointer: 0x16F4492F0, depth: 1627.27 kB
Recursion level: 59, stack pointer: 0x16F442500, depth: 1654.75 kB
Recursion level: 60, stack pointer: 0x16F43B710, depth: 1682.23 kB
Recursion level: 61, stack pointer: 0x16F434920, depth: 1709.72 kB
Recursion level: 62, stack pointer: 0x16F42DB30, depth: 1737.20 kB
Recursion level: 63, stack pointer: 0x16F426D40, depth: 1764.69 kB
Recursion level: 64, stack pointer: 0x16F41FF50, depth: 1792.17 kB
Recursion level: 65, stack pointer: 0x16F419160, depth: 1819.66 kB
Recursion level: 66, stack pointer: 0x16F412370, depth: 1847.14 kB
Recursion level: 67, stack pointer: 0x16F40B580, depth: 1874.62 kB
Recursion level: 68, stack pointer: 0x16F404790, depth: 1902.11 kB
Recursion level: 69, stack pointer: 0x16F3FD9A0, depth: 1929.59 kB
Recursion level: 70, stack pointer: 0x16F3F6BB0, depth: 1957.08 kB
Recursion level: 71, stack pointer: 0x16F3EFDC0, depth: 1984.56 kB
Recursion level: 72, stack pointer: 0x16F3E8FD0, depth: 2012.05 kB
Recursion level: 73, stack pointer: 0x16F3E21E0, depth: 2039.53 kB
Recursion level: 74, stack pointer: 0x16F3DB3F0, depth: 2067.02 kB
Recursion level: 75, stack pointer: 0x16F3D4600, depth: 2094.50 kB
Recursion level: 76, stack pointer: 0x16F3CD810, depth: 2121.98 kB
Recursion level: 77, stack pointer: 0x16F3C6A20, depth: 2149.47 kB
Recursion level: 78, stack pointer: 0x16F3BFC30, depth: 2176.95 kB
Recursion level: 79, stack pointer: 0x16F3B8E40, depth: 2204.44 kB
Recursion level: 80, stack pointer: 0x16F3B2050, depth: 2231.92 kB
Recursion level: 81, stack pointer: 0x16F3AB260, depth: 2259.41 kB
Recursion level: 82, stack pointer: 0x16F3A4470, depth: 2286.89 kB
Recursion level: 83, stack pointer: 0x16F39D680, depth: 2314.38 kB
Recursion level: 84, stack pointer: 0x16F396890, depth: 2341.86 kB
Recursion level: 85, stack pointer: 0x16F38FAA0, depth: 2369.34 kB
Recursion level: 86, stack pointer: 0x16F388CB0, depth: 2396.83 kB
Recursion level: 87, stack pointer: 0x16F381EC0, depth: 2424.31 kB
Recursion level: 88, stack pointer: 0x16F37B0D0, depth: 2451.80 kB
Recursion level: 89, stack pointer: 0x16F3742E0, depth: 2479.28 kB
Recursion level: 90, stack pointer: 0x16F36D4F0, depth: 2506.77 kB
Recursion level: 91, stack pointer: 0x16F366700, depth: 2534.25 kB
Recursion level: 92, stack pointer: 0x16F35F910, depth: 2561.73 kB
Recursion level: 93, stack pointer: 0x16F358B20, depth: 2589.22 kB
Recursion level: 94, stack pointer: 0x16F351D30, depth: 2616.70 kB
Recursion level: 95, stack pointer: 0x16F34AF40, depth: 2644.19 kB
Recursion level: 96, stack pointer: 0x16F344150, depth: 2671.67 kB
Recursion level: 97, stack pointer: 0x16F33D360, depth: 2699.16 kB
Recursion level: 98, stack pointer: 0x16F336570, depth: 2726.64 kB
Recursion level: 99, stack pointer: 0x16F32F780, depth: 2754.12 kB
Recursion level: 100, stack pointer: 0x16F328990, depth: 2781.61 kB
Recursion level: 101, stack pointer: 0x16F321BA0, depth: 2809.09 kB
Recursion level: 102, stack pointer: 0x16F31ADB0, depth: 2836.58 kB
Recursion level: 103, stack pointer: 0x16F313FC0, depth: 2864.06 kB
Recursion level: 104, stack pointer: 0x16F30D1D0, depth: 2891.55 kB
Recursion level: 105, stack pointer: 0x16F3063E0, depth: 2919.03 kB
Recursion level: 106, stack pointer: 0x16F2FF5F0, depth: 2946.52 kB
Recursion level: 107, stack pointer: 0x16F2F8800, depth: 2974.00 kB
Recursion level: 108, stack pointer: 0x16F2F1A10, depth: 3001.48 kB
Recursion level: 109, stack pointer: 0x16F2EAC20, depth: 3028.97 kB
Recursion level: 110, stack pointer: 0x16F2E3E30, depth: 3056.45 kB
Recursion level: 111, stack pointer: 0x16F2DD040, depth: 3083.94 kB
Recursion level: 112, stack pointer: 0x16F2D6250, depth: 3111.42 kB
Recursion level: 113, stack pointer: 0x16F2CF460, depth: 3138.91 kB
Recursion level: 114, stack pointer: 0x16F2C8670, depth: 3166.39 kB
Recursion level: 115, stack pointer: 0x16F2C1880, depth: 3193.88 kB
Recursion level: 116, stack pointer: 0x16F2BAA90, depth: 3221.36 kB
Recursion level: 117, stack pointer: 0x16F2B3CA0, depth: 3248.84 kB
Recursion level: 118, stack pointer: 0x16F2ACEB0, depth: 3276.33 kB
Recursion level: 119, stack pointer: 0x16F2A60C0, depth: 3303.81 kB
Recursion level: 120, stack pointer: 0x16F29F2D0, depth: 3331.30 kB
Recursion level: 121, stack pointer: 0x16F2984E0, depth: 3358.78 kB
Recursion level: 122, stack pointer: 0x16F2916F0, depth: 3386.27 kB
Recursion level: 123, stack pointer: 0x16F28A900, depth: 3413.75 kB
Recursion level: 124, stack pointer: 0x16F283B10, depth: 3441.23 kB
Recursion level: 125, stack pointer: 0x16F27CD20, depth: 3468.72 kB
Recursion level: 126, stack pointer: 0x16F275F30, depth: 3496.20 kB
Recursion level: 127, stack pointer: 0x16F26F140, depth: 3523.69 kB
Recursion level: 128, stack pointer: 0x16F268350, depth: 3551.17 kB
Recursion level: 129, stack pointer: 0x16F261560, depth: 3578.66 kB
Recursion level: 130, stack pointer: 0x16F25A770, depth: 3606.14 kB
Recursion level: 131, stack pointer: 0x16F253980, depth: 3633.62 kB
Recursion level: 132, stack pointer: 0x16F24CB90, depth: 3661.11 kB
Recursion level: 133, stack pointer: 0x16F245DA0, depth: 3688.59 kB
Recursion level: 134, stack pointer: 0x16F23EFB0, depth: 3716.08 kB
Recursion level: 135, stack pointer: 0x16F2381C0, depth: 3743.56 kB
Recursion level: 136, stack pointer: 0x16F2313D0, depth: 3771.05 kB
Recursion level: 137, stack pointer: 0x16F22A5E0, depth: 3798.53 kB
Recursion level: 138, stack pointer: 0x16F2237F0, depth: 3826.02 kB
Recursion level: 139, stack pointer: 0x16F21CA00, depth: 3853.50 kB
Recursion level: 140, stack pointer: 0x16F215C10, depth: 3880.98 kB
Recursion level: 141, stack pointer: 0x16F20EE20, depth: 3908.47 kB
Fatal Python error: _Py_CheckRecursiveCall: Unrecoverable stack overflow (used 3931 kB) while calling a Python object
Python runtime state: initialized
Current thread 0x00000001f3181f00 (most recent call first):
File "/Users/rok/Development/pyi-python314/repro.py", line 37 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
File "/Users/rok/Development/pyi-python314/repro.py", line 38 in __getattribute__
zsh: abort python3.14 repro.py
The register dump in macOS crash report shows that sp register was 6159368000 (0x16f207f40); compared to
stack pointer address reported by pthread_get_stackaddr_np, this means 4030656 bytes or 3936 kB in depth, which corroborates the Python's own error message:
Unrecoverable stack overflow (used 3931 kB) while calling a Python object
So the stack address is likely correctly initialized and stack pointer is correctly tracked, but the hard-coded limit of 4 MB is wrong; as indicated by output of pthread_get_stacksize_np, the actual stack size is 16 MB.
And for the sake of completeness - why do free-threaded version and custom build seem to pass the test without issues? Looks like the stack cost of each recursion level is (significantly) lower - presumably due to differences in build flags?
Running with free-threaded python.org build of 3.14.0b1:
Activity
StanFromIreland commentedon Mar 21, 2025
Unable to reproduce with
python3.14.0a6on Linux.encukou commentedon Mar 21, 2025
Hi,
Are the logs from that cloudpickle CI run public?
tomMoral commentedon Mar 21, 2025
I was unable to reproduce locally with linux either.
The outputs for both runs with cloudpickle CI are linked in the issue description (sorry it is not super explicit indeed)
[-]Unrecoverable stack overflow with infinite recursion on OSX[/-][+]Unrecoverable stack overflow with infinite recursion on macOS[/+]ned-deily commentedon Mar 22, 2025
I can reproduce the crash using any of the python.org macOS Python 3.14 alphas, as well as the latest python.org and MacPorts-supplied Python 3.13(.2) and 3.12(.9) - I didn't try any earlier versions of them.It might be an issue with release vs debug builds and there certainly have been many instances in the past of different stack limits on different platforms, especially on macOS.tomMoral commentedon Mar 22, 2025
Hello,
In the reported case, it does not happen with
3.14.0a5on the same platform, so I don't know if it is linked to how it is built (I'm guessing both builds have a similar process).The exact build from the logs:
3.14.0a5 (working): Download from "https://github.com/actions/python-versions/releases/download/3.14.0-alpha.5-13438582588/python-3.14.0-alpha.5-darwin-arm64.tar.gz"
3.14.0a6 (failing): Download from "https://github.com/actions/python-versions/releases/download/3.14.0-alpha.6-13890321974/python-3.14.0-alpha.6-darwin-arm64.tar.gz"
ned-deily commentedon Mar 22, 2025
My apologies! I somehow totally misread your report. Contrary to what I originally wrote, I cannot reproduce the failure with any of those python.org macOS installers, including 3.14.0a5 and a6. I see that the
actions/python-versionsrepo claims to repackage the python.org installers for macOS but I have no insight into how they might do that or what differences Github CI runners might present that might be a factor here. All I can say is that we have our own Github CI jobs for both Intel and Apple Silicon (ARM). And our python.org release installers are tested on a variety of real machines and VMs of both architectures with various macOS versions but not on a Github runner itself.ronaldoussoren commentedon Mar 23, 2025
FWIW: The reproducer in the initial message crashes for me with Python 3.14a6, but only for arm64 and not x86_64 (e.g. fatal error with
arch -arm64 python3.14 repro.pyand no issue witharch -x86_64 python3.14 repro.py). This is with the python.org installer.tests: skip recursion limits on macOS with python 3.14
tests: skip recursion limit tests on macOS with python 3.14
rokm commentedon May 25, 2025
I can reproduce the issue on my M3 Mac running macOS 15.5 with the script from OP and with python.org installer for 3.14.0b1.
Contrary to the comment above this one, the crash happens for me with both native arm64 mode and in x86_64 mode.
Interestingly, though, the crash does not happen with free-threaded version of 3.14.0b1 from python.org installer, nor if I manually compile 3.14.0b1 from source (but I haven't really tried to fully match the build flags, so that might be expected).
As far as I can tell, the problem is that
pthread_getattr_npis not available on macOS, so the stack size is set to hard-coded value of 4 MB:cpython/Python/ceval.c
Lines 467 to 469 in 91b4886
cpython/Python/ceval.c
Lines 355 to 367 in 91b4886
This is too conservative for macOS, where the python's build script explicitly increases the stack to 16 MB:
cpython/configure.ac
Lines 3597 to 3624 in b092705
So the hard-coded stack size (
Py_C_STACK_SIZE) should be raised for macOS, or even better, the actual stack size should be obtained using the macOS-specificpthread_get_stackaddr_np()andpthread_get_stacksize_np()functions.Some additional debugging info...
For testing, I've extended the OP test script with recursion level counter and a manual stack pointer tracking:
with the corresponding utility shared library to track the stack pointer:
Running with python.org build of 3.14.0b1:
Output
The register dump in macOS crash report shows that
spregister was 6159368000 (0x16f207f40); compared tostack pointer address reported by
pthread_get_stackaddr_np, this means 4030656 bytes or 3936 kB in depth, which corroborates the Python's own error message:So the stack address is likely correctly initialized and stack pointer is correctly tracked, but the hard-coded limit of 4 MB is wrong; as indicated by output of
pthread_get_stacksize_np, the actual stack size is 16 MB.And for the sake of completeness - why do free-threaded version and custom build seem to pass the test without issues? Looks like the stack cost of each recursion level is (significantly) lower - presumably due to differences in build flags?
Running with free-threaded python.org build of 3.14.0b1:
Output
Running with manually built 3.14.0b1:
Output
inventshah commentedon Aug 14, 2025
The repro is fixed in
3.14.0rc2(via #137731). @tomMoral might want to confirm with thecloudpickleCI.tomMoral commentedon Aug 25, 2025
I can confirm this is fixed, the same test now gives a comprehensive error instead of crashing the interpreter:
thanks for the fix!