You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
[CppCodeGen] Managed Exception Dispatch and Unwind #910
@jkotas I have setup corert on my local machine. I compiled this with using RyuJIT and then CPP Code Generator. Both worked and caught the exception. Could you please let me know a bit more about the issue here?
I suspect that you are not actually running the code using CoreRT - exception handling does not work yet with either RyuJIT or CppCodeGen.
Try following steps in Documentation\how-to-build-and-run-ilcompiler-in-visual-studio-2015.md or Documentation\how-to-build-and-run-ilcompiler-in-console-shell-prompt.md. The Visual Studio steps are more convenient for day to day development, just change the repro project to throw and catch exception to see the crash when you run the program.
@jkotas
Relying on C++ Exception handling seems sub optimal, while it would solve stack walking for exceptions, there are overheads to using C++ Exception handling and none of the other uses of stack walking (GC and StackTrace) would be able to leverage that overhead.
I've been reading the Book of the Runtime section on stack walking and from what I can tell, in the JITed version, stack walking is implemented using a mapping of instruction pointer ranges to function definition metadata. Allowing the stack walker to unwind each frame by doing a lookup and then moving the stack pointer backwards (based on the size specified in the looked up metadata), repeatedly until it gets where it wants to.
This seems like the most performant solution to the problem, but while its possible to get the address of a function in C++, I don't see a (portable) way to get the address of the last instruction in a function. Is RIP mapping really a dead end or is there some kind of sentinel stack cookie way I'm overlooking.
Portability is primary goal for CppCodeGen, performance is secondary. I think the C++ exception handling is the best we can do without compromising portability.
Activity
AlexBHarley commentedon Feb 21, 2016
@jkotas I have setup corert on my local machine. I compiled this with using RyuJIT and then CPP Code Generator. Both worked and caught the exception. Could you please let me know a bit more about the issue here?
jkotas commentedon Feb 21, 2016
I suspect that you are not actually running the code using CoreRT - exception handling does not work yet with either RyuJIT or CppCodeGen.
Try following steps in Documentation\how-to-build-and-run-ilcompiler-in-visual-studio-2015.md or Documentation\how-to-build-and-run-ilcompiler-in-console-shell-prompt.md. The Visual Studio steps are more convenient for day to day development, just change the repro project to throw and catch exception to see the crash when you run the program.
jkotas commentedon Jan 21, 2017
The plan should be:
Unity IP2CPP internals blog shows example of possible way to do this. Mono LLVM pure bitcode backend has same problem and it uses similar scheme to solve it.
hippiehunter commentedon Sep 16, 2017
@jkotas
Relying on C++ Exception handling seems sub optimal, while it would solve stack walking for exceptions, there are overheads to using C++ Exception handling and none of the other uses of stack walking (GC and StackTrace) would be able to leverage that overhead.
I've been reading the Book of the Runtime section on stack walking and from what I can tell, in the JITed version, stack walking is implemented using a mapping of instruction pointer ranges to function definition metadata. Allowing the stack walker to unwind each frame by doing a lookup and then moving the stack pointer backwards (based on the size specified in the looked up metadata), repeatedly until it gets where it wants to.
This seems like the most performant solution to the problem, but while its possible to get the address of a function in C++, I don't see a (portable) way to get the address of the last instruction in a function. Is RIP mapping really a dead end or is there some kind of sentinel stack cookie way I'm overlooking.
jkotas commentedon Sep 16, 2017
Portability is primary goal for CppCodeGen, performance is secondary. I think the C++ exception handling is the best we can do without compromising portability.