1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-09-28 17:39:29 +02:00

dwarf: Fix incorrect application of restore_state

Repro for a multilib binary on host x86_64:

CFLAGS="-m32" LDFLAGS="-m32" ./configure --enable-debug -- host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --libdur=/usr/lib32 --prefix=/usr --disable-documentation

make check

Gtest-init function fails trying to step through libc_start_main.  The CFA function is:

DW_CFA_def_cfa_offset: 112
DW_CFA_advance_loc: 5 to ...643
DW_CFA_restore state

Where the return address is 643.

Generally, it appears we apply all ip <= end_ip, which is incorrect in some circumstances.

libgcc only applies ip < end_ip + is_signal_frame, but that seems to break async signal handling
tests in libunwind for unknown reasons.

This is somewhat simlar to the fix in e9e8ed73e for GNU_args_size,
where the same ip check was added.
This commit is contained in:
Dave Watson 2017-08-17 12:01:16 -07:00
parent 836c91c43d
commit 3d9a694de8

View file

@ -289,8 +289,10 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
ret = -UNW_EINVAL;
break;
}
memcpy (&sr->rs_current, &(*rs_stack)->state, sizeof (sr->rs_current));
pop_rstate_stack(rs_stack);
if (*ip < end_ip) {
memcpy (&sr->rs_current, &(*rs_stack)->state, sizeof (sr->rs_current));
pop_rstate_stack(rs_stack);
}
Debug (15, "CFA_restore_state\n");
break;