This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2021-09-03.13:26:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1630675600.0.0.104145127588.issue45094@roundup.psfhosted.org>
In-reply-to
Content
I converted many C macros to static inline functions to reduce the risk of programming bugs (macros pitfalls), limit variable scopes to the function, have a more readable function, and benefit of the function name even when it's inlined in debuggers and profilers.

When Py_INCREF() macro was converted to a static inline function, using __attribute__((always_inline)) was considered, but the idea was rejected. See bpo-35059.

I'm now trying to convert the Py_TYPE() macro to a static inline function. The problem is that by default, MSC disables inlining and test_exceptions does crash with a stack overflow, since my PR 28128 increases the usage of the stack memory: see bpo-44348.

For the specific case of CPython built by MSC, we can increase the stack size, or change compiler optimizations to enable inlining. But the problem is wider than just CPython built by MSC in debug mode. Third party C extensions built by distutils may get the same issue. Building CPython on other platforms on debug mode with all compiler optimizations disabled (ex: gcc -O0) can also have the same issue.

I propose to reconsider the usage __forceinline (MSC) and __attribute__((always_inline)) (GCC, clang) on the most important static inline functions, like Py_INCREF() and Py_TYPE(), to avoid this issue.
History
Date User Action Args
2021-09-03 13:26:40vstinnersetrecipients: + vstinner
2021-09-03 13:26:40vstinnersetmessageid: <1630675600.0.0.104145127588.issue45094@roundup.psfhosted.org>
2021-09-03 13:26:39vstinnerlinkissue45094 messages
2021-09-03 13:26:39vstinnercreate