Skip to content

Wasm EH: "Delegate destination should be in scope" error #13514

@kripken

Description

@kripken

Pulled from #13485 (comment) so we don't forget, this is a fuzzer testcase that hits a clang assertion on Delegate destination should be in scope,

clang++: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp:1553: unsigned int (anonymous namespace)::WebAssemblyCFGStackify::getDelegateDepth(const SmallVectorImpl<(anonymous namespace)::WebAssemblyCFGStackify::EndMarkerInfo> &, const llvm::MachineBasicBlock *): Assertion `Depth < Stack.size() && "Delegate destination should be in scope"' failed.
#include <stdio.h> // avoid iostream C++ code, just test libc++abi, not libc++
#include <stdint.h>

extern void refuel();
extern void checkRecursion();
extern bool getBoolean();

void func_0() {
  try {
    if (getBoolean()) {
      throw 0;
    } else {
      try {
        try {
          if (getBoolean()) {
          }
        } catch(...) {
        }
      } catch(...) {
      }
    }
  } catch(...) {
  }
}

int main() {
  // func_0
  puts("calling func_0");
  refuel();
  try {
    func_0();
  } catch(...) {
    puts("main caught from func_0");
  }
  return 0;
}

STR: emcc -c a.cpp -fwasm-exceptions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions