Signed-off-by: Daniel Lehman dlehman25@gmail.com ---
some unwind handlers just need the frame; object is already on the original frame's stack also, this is consistent with FH3 code and ehandler in call_catch_block4
--- dlls/vcruntime140_1/except_x86_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/vcruntime140_1/except_x86_64.c b/dlls/vcruntime140_1/except_x86_64.c index e1a39c0662..9c48a1fdff 100644 --- a/dlls/vcruntime140_1/except_x86_64.c +++ b/dlls/vcruntime140_1/except_x86_64.c @@ -403,7 +403,7 @@ static inline void copy_exception(void *object, ULONG64 frame, DISPATCHER_CONTEX static void cxx_local_unwind4(ULONG64 frame, DISPATCHER_CONTEXT *dispatch, const cxx_function_descr *descr, int trylevel, int last_level) { - void (__cdecl *handler_dtor)(void *obj); + void (__cdecl *handler_dtor)(void *obj, ULONG64 frame); BYTE *unwind_data, *last; unwind_info ui; void *obj; @@ -442,7 +442,7 @@ static void cxx_local_unwind4(ULONG64 frame, DISPATCHER_CONTEXT *dispatch, handler_dtor = rva_to_ptr(ui.handler, dispatch->ImageBase); obj = rva_to_ptr(ui.object, frame); TRACE("handler: %p object: %p\n", handler_dtor, obj); - handler_dtor(obj); + handler_dtor(obj, frame); } } }
Hi Daniel,
In my simple tests I don't see the handler accessing edx register. Do you have code that depends on that change?
Thanks, Piotr
Do you have code that depends on that change?
all unwind handlers i see do. but i realized i can't demonstrate it without another change to how the flags in read_unwind_info are treated (was trying to send some smaller, hopefully independent commits out of order from my working tree first...)
a simple sample that demonstrates it requires a member variable: class test { public: test(int d) : id(d) { printf("ctor %x\n", id); } ~test() { printf("dtor %x\n", id); } int id; };
try { test t(0x42); throw 1; } catch (int i) { printf("catch %d\n", i); }
the 'return FALSE' for flag 0x2 in read_unwind_info has to be commented out. but with that change and this commit for the frame, you should see "ctor 0x42" and "dtor 0x42". it crashes or outputs garbage values without the frame
thanks daniel
I don't see anything wrong in current code when ui->flags == 1. Probably ui->flags == 3 case only needs the frame.
Thanks, Piotr
On 5/28/20 10:59 PM, Daniel Lehman wrote:
Do you have code that depends on that change?
all unwind handlers i see do. but i realized i can't demonstrate it without another change to how the flags in read_unwind_info are treated (was trying to send some smaller, hopefully independent commits out of order from my working tree first...)
a simple sample that demonstrates it requires a member variable: class test { public: test(int d) : id(d) { printf("ctor %x\n", id); } ~test() { printf("dtor %x\n", id); } int id; };
try { test t(0x42); throw 1; } catch (int i) { printf("catch %d\n", i); }
the 'return FALSE' for flag 0x2 in read_unwind_info has to be commented out. but with that change and this commit for the frame, you should see "ctor 0x42" and "dtor 0x42". it crashes or outputs garbage values without the frame
thanks daniel