[clang] [WinEH] Fix object delete crash (PR #180144)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 9 00:03:04 PST 2026


GkvJwa wrote:

> To me this looks wrong - if there are multiple exits out of a try region they need to be marked individually. But i guess what you are getting at is that SEH even in the presence of EHa is not connected to C++ unwinding (unlinke try/catch EHa which has a connection through state numbers). In this concrete case we are emitting `llvm.seh.scope.begin` + `llvm.seh.try.end` around the A d'tor in preparation for EHa c++ unwinding even though we don't need it. The reason this is happening is because `EHScopeStack::pushCleanup` does not differentiate between pure SEH and EHa.
> 
> So I guess a possible fix could be to not emit the EHa C++ unwind region markers if we have a pure SEH function? But this would probably require a more extensive fix.
> 
> Nesting can occur if you simply nest multiple try's. If EHa is actually used for C++ try/catch (not seh), the nesting also directly determines the current state number in the WinEHPrepare pass.

Yes, with SEH on Windows, such a deep nesting is unnecessary; SEH should be handled separately. The crash can be understood as a mismatch between begin and end.

https://github.com/llvm/llvm-project/pull/180144


More information about the cfe-commits mailing list