-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Reimplement native exception handling for PAL #308
Conversation
This change removes the preexisting exception handling in PAL that was simulating Windows SEH using a lot of low level machinery. The only remaining part is the code that raises the exception and that extracts the exception context information. The PAL_TRY, PAL_EXCEPT, PAL_FINALLY, ... macros are reimplemented using plain C++ exception handling.
@kangaroo It seems we will not need to do anything OSX specific, that's why I have made this change in my local branch. If you think there will be some OSX specific changes needed, please let me know. |
// non-NULL TRUE An exception escaped from the try block, | ||
// and the filter wanted to handle it. | ||
// | ||
|
||
#define DEBUG_OK_TO_RETURN_BEGIN(arg) | ||
#define DEBUG_OK_TO_RETURN_END(arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not seem to be used anymore in pal.h - delete?
LGTM modulo comments |
Remove few classes / macros from pal.h that are not used anymore. Fix some line continuation backslash identations.
With the previous commit, I haven't noticed that the dummy PAL_CheckVirtualUnwind() is now missing in the release build. Adding it back.
@janvorli Great, I'll try to take a look today and let you know. |
@janvorli Let me make sure I've correctly understood the effect that this will have on the CoreCLR ABI/API:
So catching exceptions thrown across the interface just got simpler, but throwing exceptions that the runtime is expected to handle remains the same (for a consumer of the API exported by the runtime), correct"? |
@pgavlin I see the change just as an internal implementation detail that the runtime or jit developers should not care about. The code should still use |
I don't think that the EH style can be considered an implementation detail, as it's fundamental to the way the runtime communicates with its consumers (hosts, JITs, etc.). Changing the EH style is a potentially breaking change even when the machinery is hidden by APIs (and I personally don't think macros are APIs, exactly). (e.g. if my consumer used C++ exceptions internally, I may now see exceptions from the runtime in my handlers). I like this change--I just want to make sure that the implications are fully understood. |
@janvorli Do you have a testcase you've been verifying against on linux? |
@kangaroo I was verifying it just with local testing pieces of code. But it is a good point, I can see now that we have a bunch of exception handling tests in the PAL that are currently disabled, so I am going to enable ones that make sense. |
@janvorli Great, that'll help me verify parity. Thanks! |
{ | ||
public: | ||
void SuppressRelease() {} | ||
}; | ||
#endif // __cplusplus | ||
|
||
#define PAL_TRY(__ParamType, __paramDef, __paramRef) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a bit more comments describing all of these macros, their parameters and usage? Thank you.
This change just adds comments to those methods.
I am removing few other things from the seh-unwind.cpp. First, the code that verified the stack unwindibility actually couldn't work since in most cases, it would reach a managed frame and then get screwed. It happened to few people in the recent past and they were mislead into thinking that it is a problem of the coreclr unwinder. There is no reasonable way to find out whether a frame is managed or native inside PAL, that's why I am removign that stuff. Also, there was now unused vectored exception handling stuff that I am also removing. Another change is in the pal.h / pal.cpp where the type of the argv parameter was const char **argv, which prevented passing in char** (the compiler was ok with it in C, but failed in C++). I have changed it to const char * const *argv, which allows passing in the char** as well.
LGTM. :) |
Reimplement native exception handling for PAL
This change removes the preexisting exception handling in PAL that was simulating Windows
SEH using a lot of low level machinery. The only remaining part is the code that raises
the exception and that extracts the exception context information.
The PAL_TRY, PAL_EXCEPT, PAL_FINALLY, ... macros are reimplemented using plain C++ exception
handling.