Skip to content

Avoid Clang bug in UBSan CI - #157958

Merged
StanFromIreland merged 3 commits into
python:mainfrom
StanFromIreland:clang-bug
Sep 30, 2026
Merged

StanFromIreland merged 3 commits into
python:mainfrom
StanFromIreland:clang-bug

Conversation

@StanFromIreland

Copy link
Copy Markdown
Member

Since 4c79929 upgraded Clang, we've been hit by llvm/llvm-project#179695. For example, in https://github.com/python/cpython/actions/runs/35756221220/job/106842645848 which took 10 minutes to compile.

Other jobs that compile with Clang aren't affected, as they are all tail-calling, and the LLVM fix was backported to 21 for Darwin.

CC @lucascolley (since this may affect your builds as well?)

@vstinner

Copy link
Copy Markdown
Member

Ah, 2 tests failed on Sanitizers / TSan (free-threading):

2 tests failed:
    test_asyncio.test_taskgroups
    test_concurrent_futures.test_process_pool

(...)

test_no_stale_references (test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_no_stale_references) ... Timeout (0:15:00)!
Thread 0x00007f5109263f40 [python] (most recent call first):
  File "/home/runner/work/cpython/cpython/Lib/multiprocessing/connection.py", line 416 in _recv
  File "/home/runner/work/cpython/cpython/Lib/multiprocessing/connection.py", line 451 in _recv_bytes
  File "/home/runner/work/cpython/cpython/Lib/multiprocessing/connection.py", line 260 in recv
  File "/home/runner/work/cpython/cpython/Lib/multiprocessing/managers.py", line 570 in start
  File "/home/runner/work/cpython/cpython/Lib/multiprocessing/context.py", line 58 in Manager
  File "/home/runner/work/cpython/cpython/Lib/test/test_concurrent_futures/util.py", line 55 in setUp

(...)

ERROR: test_taskgroup_cancel_children (test.test_asyncio.test_taskgroups.TestTaskGroup.test_taskgroup_cancel_children)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython/Lib/test/test_asyncio/test_taskgroups.py", line 1141, in test_taskgroup_cancel_children
    async with asyncio.TaskGroup() as tg:
               ~~~~~~~~~~~~~~~~~^^
  File "/home/runner/work/cpython/cpython/Lib/asyncio/taskgroups.py", line 75, in __aexit__
    return await self._aexit(et, exc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/cpython/cpython/Lib/asyncio/taskgroups.py", line 177, in _aexit
    raise propagate_cancellation_error
  File "/home/runner/work/cpython/cpython/Lib/asyncio/taskgroups.py", line 125, in _aexit
    await self._on_completed_fut
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython/Lib/asyncio/runners.py", line 128, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/runner/work/cpython/cpython/Lib/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/runner/work/cpython/cpython/Lib/test/test_asyncio/test_taskgroups.py", line 1140, in test_taskgroup_cancel_children
    async with asyncio.timeout(1):
               ~~~~~~~~~~~~~~~^^^
  File "/home/runner/work/cpython/cpython/Lib/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

@vstinner

Copy link
Copy Markdown
Member

Do you have timings before/after this change on Clang jobs?

@StanFromIreland

Copy link
Copy Markdown
Member Author

Do you have timings before/after this change on Clang jobs?

Before this patch, looking at CI runs building takes around 8-10 minutes, with the patch it takes around 1 minute.

However, this also slows down running the tests so much that we hit the 60 minute timeout. I can't reproduce that locally, so I'm not sure what's going on.

@StanFromIreland
StanFromIreland marked this pull request as draft September 23, 2026 08:35
@vstinner

Copy link
Copy Markdown
Member

Can you try -O2? According to llvm/llvm-project#179695 (comment), -O2 is not affected by the bug. It may make the tests a little big faster.

Co-authored-by: Victor Stinner <vstinner@python.org>
@StanFromIreland

Copy link
Copy Markdown
Member Author

That worked, build is now around 3 minutes, and the tests seem to be running slightly faster than currently (down to 15 minutes from an average of 18).

@StanFromIreland
StanFromIreland marked this pull request as ready for review September 23, 2026 11:13
Comment thread .github/workflows/reusable-san.yml Outdated
Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner vstinner changed the title Avoid Clang bug in UBSan CI gh-157958: Avoid Clang bug in UBSan CI Sep 23, 2026
Comment thread .github/workflows/reusable-san.yml
@vstinner

Copy link
Copy Markdown
Member

Ah, you add gh-157958: so I expected that you created an issue, but you added a reference to this PR instead. I would prefer an issue.

@vstinner

Copy link
Copy Markdown
Member

Which branches are affected?

@vstinner

Copy link
Copy Markdown
Member

If I check a recent GitHub Action job, I see:

  • Sanitizers / UBSan: 37m 42s
  • Sanitizers / TSan: 13m 49s
  • Sanitizers / TSan (free-threading): 24m 32s

On this PR, I see:

  • Tests / Sanitizers / UBSan (pull_request): 20m
  • Tests / Sanitizers / TSan (pull_request): 13m
  • Tests / Sanitizers / TSan (free-threading) (pull_request): 24m

So I see that the UBSan job is way faster: 37m 42s => 20m. The change works as expected.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StanFromIreland StanFromIreland changed the title gh-157958: Avoid Clang bug in UBSan CI Avoid Clang bug in UBSan CI Sep 30, 2026
@StanFromIreland
StanFromIreland merged commit c57c877 into python:main Sep 30, 2026
57 checks passed
@StanFromIreland
StanFromIreland deleted the clang-bug branch September 30, 2026 14:45
@StanFromIreland StanFromIreland added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 30, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @StanFromIreland, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c57c8772b0b133c5580e94006e8b084f78753f49 3.13

@bedevere-app

bedevere-app Bot commented Sep 30, 2026

Copy link
Copy Markdown

GH-158505 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 30, 2026
@bedevere-app

bedevere-app Bot commented Sep 30, 2026

Copy link
Copy Markdown

GH-158506 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 30, 2026
@StanFromIreland StanFromIreland removed the needs backport to 3.13 only security fixes label Sep 30, 2026
@bedevere-app

bedevere-app Bot commented Sep 30, 2026

Copy link
Copy Markdown

GH-158508 is a backport of this pull request to the 3.13 branch.

StanFromIreland added a commit that referenced this pull request Sep 30, 2026
(cherry picked from commit c57c877)

Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
StanFromIreland added a commit that referenced this pull request Sep 30, 2026
(cherry picked from commit c57c877)

Co-authored-by: Victor Stinner <vstinner@python.org>
hugovk pushed a commit that referenced this pull request Sep 30, 2026
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra CI, GitHub Actions, buildbots, Dependabot, etc. skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants