Skip to content

Exceptions not working even with DISABLE_EXCEPTION_CATCHING=0 #15370

Closed
@ekkxl

Description

@ekkxl

I'm working on developing a programming language, which directly generates LLVM files which I compile with emscripten to generate JS files. Everything works except exceptions which are not being caught properly. I'm building with -fexception and -s DISABLE_EXCEPTION_CATCHING=0. More strange is I also have a runtime library written in C++, and exceptions are being caught there. So an example stack trace

  1. some_function_that_throws
  2. some_function_that_catches
  3. cpp_function_that_catches

The exception should be caught by 2 but is being caught by 3. Same problem with WASM on or off. Here's a snippet of my LLVM assembly:

	invoke void @K_throw( %t_struct %t_16 ) to label %label_7 unwind label %label_6
label_7:
	; some code
label_6:
	%t_49 = landingpad { i8*, i32 } cleanup
	store { i8*, i32 } %t_49, { i8*, i32 }* %exceptionInfo
	%t_49_exception_value = extractvalue { i8*, i32 } %t_49, 0
	store i8* %t_49_exception_value, %t_exception* %exception
	; more code

So in this case K_throw will throw, but it's not being caught by the landingpad, Looking at the generated JS code with WASM off, I see that it's not even generating an invoke_XXX call for the call to K_throw.

I've tried compiling the C++ runtime files with -S emit-llvm and compared that to the LLVM code I'm generated, and I don't see any significant difference in the way I'm defining functions, personality functions, landing pads, etc.

All of this code worked perfectly under an old version of emscripten (1.37.21). I updated to the latest version (2.0.32) and exceptions stopped working without any changes to my files.

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