Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-39573: Py_TYPE becomes a static inline function #28128

Merged
merged 2 commits into from
Sep 8, 2021
Merged

bpo-39573: Py_TYPE becomes a static inline function #28128

merged 2 commits into from
Sep 8, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 2, 2021

Convert the Py_TYPE() and Py_SIZE() macros to static inline
functions. The Py_SET_TYPE() and Py_SET_SIZE() functions must now be
used to set an object type and size.

https://bugs.python.org/issue39573

@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2021

I already pushed this change in June: f3fa63e

But it was reverted since it broke a Windows debug buildbot and I failed to find time to analyze why: https://bugs.python.org/issue39573#msg395205

@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 2, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @vstinner for commit d57df229d34be7a608ccf62237148542b34f1cd5 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 2, 2021
@vstinner
Copy link
Member Author

vstinner commented Sep 3, 2021

buildbot/AMD64 Windows10 PR failed:

Py_DEBUG: Yes (sys.gettotalrefcount() present)
...
Windows fatal exception: stack overflow
Current thread 0x000012f8 (most recent call first):
  File "D:\buildarea\pull_request.bolen-windows10\build\lib\test\test_exceptions.py", line 1313 in test_recursion_in_except_handler

buildbot/AMD64 Windows10 Pro PR: failed

Py_DEBUG: Yes (sys.gettotalrefcount() present)
...
Windows fatal exception: stack overflow
Current thread 0x000022e8 (most recent call first):
  File "C:\buildbot.python.org\pull_request.kloth-win64\build\lib\test\test_exceptions.py", line 1313 in test_recursion_in_except_handler

buildbot/AMD64 Arch Linux Asan Debug PR:

(...)
  File "/buildbot/buildarea/pull_request.pablogsal-arch-x86_64.asan_debug/build/Lib/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/buildbot/buildarea/pull_request.pablogsal-arch-x86_64.asan_debug/build/Lib/subprocess.py", line 1775, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: subprocess not supported for isolated subinterpreters

Hum, usually this error comes from an incremental build: a C structure changed, the compiler reused old object files (.o).

buildbot/x86 Gentoo Non-Debug with X PR:

0:36:34 load avg: 8.91 [239/427/1] test_peg_generator crashed (Exit code 1)
Timeout (0:25:00)!
Thread 0xb7bc1700 (most recent call first):
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/subprocess.py", line 1896 in _try_wait
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/subprocess.py", line 1938 in _wait
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/subprocess.py", line 1204 in wait
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/spawn.py", line 80 in spawn
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/ccompiler.py", line 910 in spawn
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/unixccompiler.py", line 117 in _compile
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/ccompiler.py", line 574 in compile
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/command/build_ext.py", line 529 in build_extension
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/command/build_ext.py", line 474 in _build_extensions_serial
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/command/build_ext.py", line 449 in build_extensions
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/distutils/command/build_ext.py", line 340 in run
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Tools/peg_generator/pegen/build.py", line 93 in compile_c_extension
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Tools/peg_generator/pegen/testutil.py", line 105 in generate_parser_c_extension
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/test/test_peg_generator/test_c_parser.py", line 93 in build_extension
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/test/test_peg_generator/test_c_parser.py", line 96 in run_test
  File "/buildbot/buildarea/cpython/pull_request.ware-gentoo-x86.nondebug/build/Lib/test/test_peg_generator/test_c_parser.py", line 257 in test_return_stmt_noexpr_action
(...)

It seems like the timeout is just too low for this slow buildbot. On a previous build, the test took 21 min which is close to the timeout of 25 min:

https://buildbot.python.org/all/#/builders/344/builds/151

10 slowest tests:
- test_peg_generator: 21 min 46 sec

@Fidget-Spinner
Copy link
Member

For the test_exceptions bug, there's an issue at https://bugs.python.org/issue44348. Some time ago I proposed that we need to increase stack size on windows.

@vstinner
Copy link
Member Author

vstinner commented Sep 3, 2021

I created python/buildmaster-config#262 to increase "/x86 Gentoo Non-Debug with X" buildbot timeout: python/buildmaster-config@eeff117

@Fidget-Spinner: "For the test_exceptions bug, there's an issue at https://bugs.python.org/issue44348. Some time ago I proposed that we need to increase stack size on windows."

Right, I'm aware of that. But I was optimistic and hoped that the bug gone magically :-)

For test_exceptions, my notes on the stack size and stack overflow on a recursion error on Windows: https://pythondev.readthedocs.io/unstable_tests.html#unlimited-recursion

@vstinner
Copy link
Member Author

vstinner commented Sep 3, 2021

I created https://bugs.python.org/issue45094 for the test_exceptions stack overflow.

@vstinner vstinner marked this pull request as draft September 3, 2021 23:24
@vstinner
Copy link
Member Author

vstinner commented Sep 3, 2021

I converted this PR to a draft until https://bugs.python.org/issue45094 is fixed.

I pushed changes to test if Py_ALWAYS_INLINE (PR #28141) would fix the test_exceptions on Windows when Python is built in debug mode.

@vstinner
Copy link
Member Author

vstinner commented Sep 3, 2021

Oh, it seems like adding __declspec(noinline) didn't fix test_exceptions, or my PR has an issue, or __declspec(noinline) is ignored when Python is built in debug mode.

Windows fatal exception: stack overflow
0:06:07 load avg: 8.17 [236/427/1] test_exceptions crashed (Exit code 3221225725)

Current thread 0x00000348 (most recent call first):
  File "D:\a\cpython\cpython\lib\test\test_exceptions.py", line 1313 in test_recursion_in_except_handler

@vstinner
Copy link
Member Author

vstinner commented Sep 6, 2021

New approach: bpo-45115: Enable optimiaztions on Windows debug build. I included PR #28181 in this PR, to see if PR #28181 fix test_exceptions.

@vstinner
Copy link
Member Author

vstinner commented Sep 7, 2021

I pushed a change to run the test suite with a debug mode on Windows (commit " [WIP] GitHub Action: Windows uses a debug build"): tests now pass thanks to my test_exceptions fix!

Convert the Py_TYPE() and Py_SIZE() macros to static inline
functions. The Py_SET_TYPE() and Py_SET_SIZE() functions must now be
used to set an object type and size.
@vstinner vstinner marked this pull request as ready for review September 7, 2021 16:48
@vstinner
Copy link
Member Author

vstinner commented Sep 7, 2021

I removed the debug commits of this PR (since tests pass) and I removed the Draft status.

Don't use _PyObject_CAST() which doesn't exist in old Python versions.
@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 7, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @vstinner for commit d411467 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 7, 2021
@vstinner
Copy link
Member Author

vstinner commented Sep 7, 2021

buildbot/AMD64 Arch Linux Asan Debug PR

The compile step failed with "RuntimeError: subprocess not supported for isolated subinterpreters". This issue is unrelated to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants