Peter Zion
2011-Jul-12 23:25 UTC
[LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
Hi All, I'm trying to catch an exception that is "passed through" an LLVM ExecutionEngine but I am unable to do so. Specifically, in C++ code, inside a try/catch block, I call a JITted function, which in turn calls back into my code. Everything works fine unless an exception is thrown; I would except the outermost try/catch(...) block to catch the exception thrown in my innermost C++ code, but instead I get the abort "terminate called after throwing an instance of 'MyException'". I am compiling the system with g++ (on Linux and OSX); I haven't tried MSVC++. Is there something that I need to do to get this behaviour to work? I admit that I have only a fairly basic understanding of how exception handling is implemented in C++ but from what I've read it seems like the exception should unwind through what is, for all intents and purposes, a simple call stack... Thanks, Peter Zion
Garrison Venn
2011-Jul-21 21:45 UTC
[LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
Sorry Peter, just saw this. If you are still having the problem: Did you set: llvm::JITExceptionHandling = true; ? Garrison On Jul 12, 2011, at 19:25, Peter Zion wrote:> Hi All, > > I'm trying to catch an exception that is "passed through" an LLVM ExecutionEngine but I am unable to do so. Specifically, in C++ code, inside a try/catch block, I call a JITted function, which in turn calls back into my code. Everything works fine unless an exception is thrown; I would except the outermost try/catch(...) block to catch the exception thrown in my innermost C++ code, but instead I get the abort "terminate called after throwing an instance of 'MyException'". I am compiling the system with g++ (on Linux and OSX); I haven't tried MSVC++. > > Is there something that I need to do to get this behaviour to work? I admit that I have only a fairly basic understanding of how exception handling is implemented in C++ but from what I've read it seems like the exception should unwind through what is, for all intents and purposes, a simple call stack... > > Thanks, > Peter Zion > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Peter Zion
2011-Jul-21 21:47 UTC
[LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
Yes, I did -- it made no difference. Should it? Note that I have since discovered that this is not a problem on Windows -- the exception drops through as expected. pz On 2011-07-21, at 5:45 PM, Garrison Venn wrote:> Sorry Peter, just saw this. > > If you are still having the problem: > > Did you set: llvm::JITExceptionHandling = true; ? > > Garrison > > On Jul 12, 2011, at 19:25, Peter Zion wrote: > >> Hi All, >> >> I'm trying to catch an exception that is "passed through" an LLVM ExecutionEngine but I am unable to do so. Specifically, in C++ code, inside a try/catch block, I call a JITted function, which in turn calls back into my code. Everything works fine unless an exception is thrown; I would except the outermost try/catch(...) block to catch the exception thrown in my innermost C++ code, but instead I get the abort "terminate called after throwing an instance of 'MyException'". I am compiling the system with g++ (on Linux and OSX); I haven't tried MSVC++. >> >> Is there something that I need to do to get this behaviour to work? I admit that I have only a fairly basic understanding of how exception handling is implemented in C++ but from what I've read it seems like the exception should unwind through what is, for all intents and purposes, a simple call stack... >> >> Thanks, >> Peter Zion >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Geoff Reedy
2011-Jul-21 21:56 UTC
[LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
On Tue, Jul 12, 2011 at 07:25:16PM -0400, Peter Zion said> Hi All, > > I'm trying to catch an exception that is "passed through" an LLVM ExecutionEngine but I am unable to do so. Specifically, in C++ code, inside a try/catch block, I call a JITted function, which in turn calls back into my code. Everything works fine unless an exception is thrown; I would except the outermost try/catch(...) block to catch the exception thrown in my innermost C++ code, but instead I get the abort "terminate called after throwing an instance of 'MyException'". I am compiling the system with g++ (on Linux and OSX); I haven't tried MSVC++. > > Is there something that I need to do to get this behaviour to work? I admit that I have only a fairly basic understanding of how exception handling is implemented in C++ but from what I've read it seems like the exception should unwind through what is, for all intents and purposes, a simple call stack...There was an example program detailing how to do exactly this on the wiki. Was the wiki content archived before it was taken down?
Geoff Reedy
2011-Jul-21 22:03 UTC
[LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
On Thu, Jul 21, 2011 at 03:56:21PM -0600, Geoff Reedy said> On Tue, Jul 12, 2011 at 07:25:16PM -0400, Peter Zion said > > Hi All, > > > > I'm trying to catch an exception that is "passed through" an LLVM ExecutionEngine but I am unable to do so. Specifically, in C++ code, inside a try/catch block, I call a JITted function, which in turn calls back into my code. Everything works fine unless an exception is thrown; I would except the outermost try/catch(...) block to catch the exception thrown in my innermost C++ code, but instead I get the abort "terminate called after throwing an instance of 'MyException'". I am compiling the system with g++ (on Linux and OSX); I haven't tried MSVC++. > > > > Is there something that I need to do to get this behaviour to work? I admit that I have only a fairly basic understanding of how exception handling is implemented in C++ but from what I've read it seems like the exception should unwind through what is, for all intents and purposes, a simple call stack... > > There was an example program detailing how to do exactly this on the > wiki. Was the wiki content archived before it was taken down?Actually, I see that the example code I was thinking of is in examples/ExceptionDemo/ExceptionDemo.cpp of the LLVM source distribution. The wiki page, as I recall, had some additional exposition that's not in the source file.
Garrison Venn
2011-Jul-21 22:05 UTC
[LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
Although I did not archive the wiki entry, the code is at llvm/examples/ExceptionDemo/ExceptionDemo.cpp and is built (for OS X and Linux) by building llvm with the environment var BUILD_EXAMPLES set to 1. Garrison On Jul 21, 2011, at 17:56, Geoff Reedy wrote:> On Tue, Jul 12, 2011 at 07:25:16PM -0400, Peter Zion said >> Hi All, >> >> I'm trying to catch an exception that is "passed through" an LLVM ExecutionEngine but I am unable to do so. Specifically, in C++ code, inside a try/catch block, I call a JITted function, which in turn calls back into my code. Everything works fine unless an exception is thrown; I would except the outermost try/catch(...) block to catch the exception thrown in my innermost C++ code, but instead I get the abort "terminate called after throwing an instance of 'MyException'". I am compiling the system with g++ (on Linux and OSX); I haven't tried MSVC++. >> >> Is there something that I need to do to get this behaviour to work? I admit that I have only a fairly basic understanding of how exception handling is implemented in C++ but from what I've read it seems like the exception should unwind through what is, for all intents and purposes, a simple call stack... > > There was an example program detailing how to do exactly this on the > wiki. Was the wiki content archived before it was taken down? > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Seemingly Similar Threads
- [LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
- [LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
- [LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
- [LLVMdev] Catching exceptions passed through a JIT ExecutionEngine
- glmmPQL and predict