Lines 1-48
Link Here
|
1 |
--- src/exception.cc.orig 2013-12-26 03:11:27 UTC |
|
|
2 |
+++ src/exception.cc |
3 |
@@ -304,13 +304,17 @@ static pthread_key_t eh_key; |
4 |
static void exception_cleanup(_Unwind_Reason_Code reason, |
5 |
struct _Unwind_Exception *ex) |
6 |
{ |
7 |
- __cxa_free_exception(static_cast<void*>(ex)); |
8 |
+ // Exception layout: |
9 |
+ // [__cxa_exception [_Unwind_Exception]] [exception object] |
10 |
+ // |
11 |
+ // __cxa_free_exception expects a pointer to the exception object |
12 |
+ __cxa_free_exception(static_cast<void*>(ex + 1)); |
13 |
} |
14 |
static void dependent_exception_cleanup(_Unwind_Reason_Code reason, |
15 |
struct _Unwind_Exception *ex) |
16 |
{ |
17 |
|
18 |
- __cxa_free_dependent_exception(static_cast<void*>(ex)); |
19 |
+ __cxa_free_dependent_exception(static_cast<void*>(ex + 1)); |
20 |
} |
21 |
|
22 |
/** |
23 |
@@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_ |
24 |
if (info->foreign_exception_state != __cxa_thread_info::none) |
25 |
{ |
26 |
_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions); |
27 |
- e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); |
28 |
+ if (e->exception_cleanup) |
29 |
+ e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); |
30 |
} |
31 |
else |
32 |
{ |
33 |
@@ -1270,12 +1275,13 @@ extern "C" void __cxa_end_catch() |
34 |
|
35 |
if (ti->foreign_exception_state != __cxa_thread_info::none) |
36 |
{ |
37 |
- globals->caughtExceptions = 0; |
38 |
if (ti->foreign_exception_state != __cxa_thread_info::rethrown) |
39 |
{ |
40 |
_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions); |
41 |
- e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); |
42 |
+ if (e->exception_cleanup) |
43 |
+ e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); |
44 |
} |
45 |
+ globals->caughtExceptions = 0; |
46 |
ti->foreign_exception_state = __cxa_thread_info::none; |
47 |
return; |
48 |
} |