Repository navigation
clang-cl on Windows incorrectly compiles SEH (structured exception handling) #131691
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Mar 24, 2025 Even more weird workaround: wrap the "body" (here
sourcecode) in a separate function and guard that via SEH.I thought we were already doing that? I tried to make sure it was designed that way (e.g. the "safe_*" functions) so that it's clear where the protection starts and ends, and we don't have to worry about any state (e.g. no calls back into Python are possible). The macro should just be to help implement those with less repetition (not my preference, but someone else was doing the PR).
But looking a little further down the llvm issue, it sounds like they just gave
/EHaa slightly different meaning. So if it can be specified for Clang (I assume theClCompile.ExceptionHandlingmetadata is interpreted here?) but not MSVC then it seems that should be fine.Reacted by Chris Eibl- addedtestsTests in the Lib/test dirTests in the Lib/test dirextension-modulesC modules in the Modules dirC modules in the Modules dir
on Mar 25, 2025 - changed the title
[-]test_mmap.MmapTests.test_access_violations fails for clang-cl builds on Windows[/-][+]clang-cl on Windows incorrectly handles SEH exception handling[/+]on Mar 25, 2025 Yeah, since SEH is also used in
sqlite3.candctypes(and up to recently for stack checking via_alloca), let's set<ExceptionHandling>Async</ExceptionHandling>inpyproject-clangcl.propsso that all source files are compiled with it: #131730- changed the title
[-]clang-cl on Windows incorrectly handles SEH exception handling[/-][+]clang-cl on Windows incorrectly compiles SEH (structuered exception handling)[/+]on Mar 25, 2025 - changed the title
[-]clang-cl on Windows incorrectly compiles SEH (structuered exception handling)[/-][+]clang-cl on Windows incorrectly compiles SEH (structured exception handling)[/+]on Mar 25, 2025 - added a commit that references this issue
on Mar 25, 2025
Bug report
Bug description:
clang-cl incorrectly handles SEH exception handling: llvm/llvm-project#62606
E.g. in
cpython/Modules/mmapmodule.c
Lines 353 to 360 in 7c3692f
where
cpython/Modules/mmapmodule.c
Lines 297 to 316 in 7c3692f
This lets
test_mmap.MmapTests.test_access_violationsfail for clang-cl builds on Windows,see e.g. https://github.com/python/cpython/actions/runs/14044831663/job/39323183797?pr=131690#step:4:566.
The suggestion in llvm/llvm-project#62606 (comment) is to use
EHa,which seems wrong, and clearly is a compatibility issue wrt to MSVC.
Since Python code is compiled in C mode,
EHawould seem really weird to me. Even more weird workaround: wrap the "body" (heresourcecode) in a separate function and guard that via SEH.I've tried both workarounds and they would fix the problem.
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Linked PRs