__attribute__((cleanup(function)) versus try/finally
Mike Stump
mrs@apple.com
Thu May 8 18:02:00 GMT 2003
On Wednesday, May 7, 2003, at 03:19 AM, Ranjit Mathew wrote:
> Now I have an issue somewhat related to this
> discussion that I hope someone would be able to
> shed some light on: on Windows, the Cygwin/MinGW
> targets have had to give up on DW2 EH in favour of
> SJLJ purely because exceptions could not be
> thrown from a callback function, across the
> Windows Event Dispatcher stack to the handler
> of the exception.
This can be made to work given an integrated sjlj/dwarf2 EH scheme. At
transition points into and out of code compiled by other compilation
systems (or -fno-exception code), we introduce a sjlj cleanup point
there. For, take for example:
foo() {
DispatchMessage();
}
we have to know that DispatchMessage is going to go to `outside',
imagine if you will:
#pragma gcc EH doesnt have unwind tables: DispatchMessage
foo() {
...
DispatchMessage();
...
}
then it is a simple process to generate:
foo() {
...
sjljtry {
DispatchMessage();
} catch (...) {
rethrow;
}
...
}
instead. We can get back `into' the unwind tables by doing the lj back
to this point.
> In fact, this seems to be a fundamental limitation
> of the DW2 EH mechanism and not just on Windows.
An unimplemented feature, I'd say, not a fundamental limitation.
Though, such a change would be probably have ABI impact, as only the
enhanced thrower would be able to fall back to doing the throw when it
runs out of unwind information.
More information about the Gcc
mailing list