Skip to content

Commit

Permalink
Fix sanitizer frame unwind on 32-bit ABIs (again)
Browse files Browse the repository at this point in the history
This re-applies r258525, and this time adds it to LOCAL_PATCHES.


libsanitizer/
	* LOCAL_PATCHES: Add r258525.
	* sanitizer_common/sanitizer_stacktrace.cc
	(BufferedStackTrace::FastUnwindStack): Use the correct frame offset
	for PowerPC SYSV ABI.

From-SVN: r265817
  • Loading branch information
segher authored and Segher Boessenkool committed Nov 5, 2018
1 parent 510e072 commit b40a67d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions libsanitizer/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2018-11-05 Segher Boessenkool <[email protected]>

* LOCAL_PATCHES: Add r258525.
* sanitizer_common/sanitizer_stacktrace.cc
(BufferedStackTrace::FastUnwindStack): Use the correct frame offset
for PowerPC SYSV ABI.

2018-11-05 Martin Liska <[email protected]>

PR sanitizer/87860
Expand Down
1 change: 1 addition & 0 deletions libsanitizer/LOCAL_PATCHES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
r258525
r265667
r265668
r265669
13 changes: 10 additions & 3 deletions libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,21 @@ void BufferedStackTrace::FastUnwindStack(uptr pc, uptr bp, uptr stack_top,
IsAligned((uptr)frame, sizeof(*frame)) &&
size < max_depth) {
#ifdef __powerpc__
// PowerPC ABIs specify that the return address is saved at offset
// 16 of the *caller's* stack frame. Thus we must dereference the
// back chain to find the caller frame before extracting it.
// PowerPC ABIs specify that the return address is saved on the
// *caller's* stack frame. Thus we must dereference the back chain
// to find the caller frame before extracting it.
uhwptr *caller_frame = (uhwptr*)frame[0];
if (!IsValidFrame((uptr)caller_frame, stack_top, bottom) ||
!IsAligned((uptr)caller_frame, sizeof(uhwptr)))
break;
// For most ABIs the offset where the return address is saved is two
// register sizes. The exception is the SVR4 ABI, which uses an
// offset of only one register size.
#ifdef _CALL_SYSV
uhwptr pc1 = caller_frame[1];
#else
uhwptr pc1 = caller_frame[2];
#endif
#elif defined(__s390__)
uhwptr pc1 = frame[14];
#else
Expand Down

0 comments on commit b40a67d

Please sign in to comment.