Issue 240257
Summary [X86][SLH] Windows C++ EH triggers Only Itanium ABI EH supported assertion
Labels new issue
Assignees
Reporter zjy-dev
    An assertion-enabled Clang crashes when compiling C++ exception handling for the MSVC target with `-mspeculative-load-hardening`. The pass rejects the EH form through an assertion rather than a user-facing unsupported-configuration diagnostic.

Reproduced with Compiler Explorer's `clang_assertions_trunk` on 2026-11-09 (exit code 134, SIGABRT). The corresponding non-assertions trunk build and our Clang 23.1.2 build (`85ac560262434c9ccfc0c183ec22d4138ed647fb`) emit assembly without diagnosing this combination.

### Reproducer

Save as `trigger.cpp`:

```cpp
extern "C" int sink(int);
extern volatile int *g_p;

__attribute__((speculative_load_hardening))
int guarded_catch(int idx) {
  int acc = 0;
  try {
    if (idx > 3)
      throw 7;
    acc = *g_p;
  } catch (int v) {
    acc = v + sink(idx);
    if (acc < 0)
 acc = *g_p;
  }
  return acc;
}
```

```sh
clang++ --target=x86_64-pc-windows-msvc -O2 -fexceptions \
  -fcxx-exceptions -mspeculative-load-hardening -S trigger.cpp -o trigger.s
```

No Windows SDK headers or link step are needed.

### Observed diagnostic

```text
clang++: /root/llvm-project/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp:487:
bool {anonymous}::X86SpeculativeLoadHardeningImpl::run(llvm::MachineFunction&):
Assertion `!MBB.isEHScopeEntry() && "Only Itanium ABI EH supported!"' failed.
```

Relevant stack frames:

```text
Running pass 'X86 speculative load hardening' on function '@"?guarded_catch@@YAHH@Z"'
(anonymous namespace)::X86SpeculativeLoadHardeningImpl::run(llvm::MachineFunction&)
(anonymous namespace)::X86SpeculativeLoadHardeningLegacy::runOnMachineFunction(llvm::MachineFunction&)
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
Program terminated with signal SIGABRT (6)
```

### Expected behavior

Either support the Windows EH entry/exit conventions or diagnose the unsupported combination consistently in assertions and release builds.

The source check in `llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp` exists only as an assertion. In 23.1.2 the corresponding code checks `isEHFuncletEntry()`; current trunk checks `isEHScopeEntry()`. A deliberate diagnostic would avoid the compiler crash and make the support boundary clear.

This report concerns the reproducible compiler assertion and absent diagnostic. It does not claim runtime stack corruption or a demonstrated SLH bypass.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to