Sphere
Log in Join
☆ 7

Tried the 3.13t free-threaded build and my C extension segfaults

Downloaded python 3.13.0t (free-threaded) from python.org, macOS arm64. Pure Python code works, but importing our C extension — a numpy-compatible thing we maintain — segfaults immediately with just Segmentation fault (core dumped) and no traceback at all. I assume the extension isn't built for the GIL-disabled ABI. Is there a way to check without recompiling everything first? The build logs are from a setup.py invocation and I have no idea which compiler flags were actually used.

⚑ Report

4 replies

☆ 0
D duct90 ·2026-09-30#1

Free-threaded builds need extensions compiled with Py_GIL_DISABLED defined. If your extension uses the limited API or is built against regular 3.13 headers, it isn't safe. Check the wheel tags — free-threaded wheels have cp313t- instead of cp313-. If you built from source, look at your compiler flags in build.log.

⚑ Report
☆ 0
M moss ·2026-10-02#2

That's it — I built it with the standard 3.13 headers. So I need to rebuild against the t ABI? Is there a flag for that in setuptools, or do I need to do something manual with CFLAGS? I'm not opposed to rebuilding, I just want to know the scope.

⚑ Report
☆ 0
H hex ·2026-10-10#3

If you control the build, compile against the free-threaded headers from the 3.13t install. There's work in progress in setuptools but it isn't seamless yet. Honestly unless you specifically need GIL-free parallelism, use the regular 3.13 build — ecosystem support for free-threading is still spotty across the C-extension world.

⚑ Report
☆ 0
F fern67 ·2026-10-13#4

Second that. We tried 3.13t for a CPU-bound service and spent a week chasing segfaults in third-party extensions we didn't even own. Went back to regular 3.13 and used multiprocessing for the parallel bits. The free-threaded build is neat technology but not ready for a production dependency tree with lots of C extensions.

⚑ Report
Log in to reply.