[New-bugs-announce] [issue38301] If "_REENTARNT" is defined in the header file, we should use "-D_REENTRANT" when compiling

Jesús Cea Avión report at bugs.python.org
Fri Sep 27 17:35:16 EDT 2019

New submission from Jesús Cea Avión <jcea at jcea.es>:

When compiling on Solaris family, we define "_REENTRANT" in "Pyconfig.h".  That file is included when compiling C extensions, but if the extension is made of several C files, it could be included only in the file that interfaces with python runtime.

Unfortunately, "_REENTRANT" modifies the way C code is compiled, so compiling a C extension with some source files with "_REENTRANT" and some other without that "define" can produce bizarre errors and crashes.

One example: https://github.com/joyent/pkgsrc/issues/207

In particular, "include" order can make a big difference: https://github.com/jnwatson/py-lmdb/issues/213

I suggest that when "_REENTRANT" is defined in "Pyconfig.h", Python C extensions compilation machinery adds "-D_REENTRANT" to the compilation flags.

The patch is trivial.

assignee: jcea
components: Build
messages: 353416
nosy: jcea
priority: high
severity: normal
status: open
title: If "_REENTARNT" is defined in the header file, we should use "-D_REENTRANT" when compiling
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list