[Python-Dev] Pythreads and BSD descendants

"Martin v. Löwis" martin at v.loewis.de
Sat Aug 4 00:46:39 CEST 2007

Cameron Laird schrieb:
> Folklore that I remember so unreliably I avoid trying to repeat it here
> held that Python threading had problems on BSD and allied Unixes.  What's
> the status of this?

The problem that people run into again and again is the stack size. The
BSDs allow for so little stack so that even the quite conservative
estimates of Python as to how many recursions you can have are
incorrect, and you get an interpreter crash rather than a RuntimeError
(as you should).

Furthermore, every time we decrease the that number, the next system
release somehow manages to make the limit even smaller. This was
never properly analyzed; I suspect that the stack usage of Python
increases, either due to compiler changes or due to change to Python

Another annoyance is the ongoing battle with Posix; the BSDs have
not been very accepting towards Posix for many years. This resulted
in an interpretation of Posix where defining _XOPEN_SOURCE hides
many system interfaces, resulting in these system interfaces either
not being present, or compilation to fail. I consider this a bug
in the system: compilation should *never* fail if you define
_XOPEN_SOURCE, and additional interfaces should be available if
requested (that requires a way to request them). The work-around
was to not define _XOPEN_SOURCE for those buggy system releases,
hoping that the next release would fix the bug. Over the years,
the maintainers of these systems seem to have come to a better
understanding, so they offer various custom _SOURCE macros
(_NETBSD_SOURCE, __BSD_VISIBLE). The latest addition here was
OpenBSD, which now supports _BSD_SOURCE (apparently following a
tradition set by GNU libc, and perhaps others). So I hope this is
fixed for good now (except that FreeBSD may decide to break
__BSD_VISIBLE the same way it got "broken" in OpenBSD, so we
need to add their "official" feature selection macro once we
find out what that is). The same problem exists of course on many
other systems, but those solved the problem long ago (e.g.
_GNU_SOURCE - glibc, _BSD_TYPES - Irix)


More information about the Python-Dev mailing list