Initial Checks
Description
On musl-based Python installed with uv, if Pydantic is called from a thread other than the main thread, the entire process is killed by SIGSEGV.
A minimal reproducible example is available at https://github.com/satgo1546/pydantic-segfault-mwe.
I have confirmed this behavior on:
- Alpine Linux 3.23 x86_64
- Alpine Linux 3.23 arm64
- Ubuntu 24.04 x86_64 with musl-tools installed
- Ubuntu 24.04 arm64 with musl-tools installed
Note that uv uses distributions from the Astral python-build-standalone project instead of the official python.org binaries. The problem is gone with official python.org binaries.
Example Code
# Note that the is bug only reproducible on uv-installed musl-based Python.
# A minimal reproducible example is available at <https://github.com/satgo1546/pydantic-segfault-mwe>.
import threading
from pydantic import BaseModel
class MyModel(BaseModel):
a: str
threading.Thread(target=lambda: MyModel.model_validate_json('{"a":"ok"}')).start()
Python, Pydantic & OS Version
pydantic version: 2.12.5
pydantic-core version: 2.41.5
pydantic-core build: profile=release pgo=false
python version: 3.14.3 (main, Mar 3 2026, 14:58:03) [Clang 21.1.4 ]
platform: Linux-6.12.69-0-rpi-aarch64-with-musl1
related packages: typing_extensions-4.15.0
commit: unknown
pydantic version: 2.12.5
pydantic-core version: 2.41.5
pydantic-core build: profile=release pgo=false
python version: 3.11.15 (main, Mar 24 2026, 22:50:51) [Clang 22.1.1 ]
platform: Linux-6.17.0-1008-azure-x86_64-with-libc
related packages: typing_extensions-4.15.0
commit: unknown
pydantic version: 2.12.5
pydantic-core version: 2.41.5
pydantic-core build: profile=release pgo=false
python version: 3.11.15 (main, Mar 24 2026, 22:45:42) [Clang 22.1.1 ]
platform: Linux-6.14.0-1017-azure-aarch64-with-libc
related packages: typing_extensions-4.15.0
commit: unknown
Initial Checks
Description
On musl-based Python installed with uv, if Pydantic is called from a thread other than the main thread, the entire process is killed by SIGSEGV.
A minimal reproducible example is available at https://github.com/satgo1546/pydantic-segfault-mwe.
I have confirmed this behavior on:
Note that uv uses distributions from the Astral python-build-standalone project instead of the official python.org binaries. The problem is gone with official python.org binaries.
Example Code
Python, Pydantic & OS Version