[llvm-dev] Windows: How to catch C++ exceptions in runtime-compiled code?

Timur Doumler via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 10 09:13:34 PDT 2016


Hey Igor,

Thanks a lot for your e-mail! I am Cc’ing Stefan Gränitz who is the one actually working on this project, hope this will be helpful.

Cheers, Timur

> On 10 Jun 2016, at 15:07, Igor Minin <igorm6387 at gmail.com> wrote:
> 
> Hi, Timur. I may be wrong, but it seems that I faced similar problem before. 
> 
> The problem is that Windows checks memory region of exception handler for MEM_EXECUTE_OPTION_EXECUTE_DISPATCH_ENABLE flag, that is not set by default and can't be set easily.
> 
> Before Windows passes control to your handler it does the following checks:
> 
> KiUserExceptionDispatcher ->RtlDispatchException -> RtlIsValidHandler (FAIL)
> 
> So you need to enable this flag for your memory-generated code. As far as I know it is impossible if permanent DEP is enabled. So you can either run your process without DEP (not an option in the most cases), or use another way to deal with exceptions. One of the possible workarounds is VEH. You can look through OpenJDK as an example.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160610/e77f7f8e/attachment.html>


More information about the llvm-dev mailing list