forked from OSchip/llvm-project
[Sanitizer] Fix segfaults during unwinding on SystemZ
Every now and then SystemZ programs built with ASan crash with ERROR: AddressSanitizer: stack-overflow on address 0x040000000000 for no apparent reason. The problem is that BufferedStackTrace::UnwindFast() is specialized for SystemZ: it takes register 14 from the frame, however, IsValidFrame() is not specialized, and does not guarantee that frame[14] is going to be a valid memory access. Fix by introducing per-arch kFrameSize and using it in IsValidFrame(). Reviewed By: uweigand Differential Revision: https://reviews.llvm.org/D85822
This commit is contained in:
parent
304264e73d
commit
eca4b4007d
|
@ -143,9 +143,17 @@ struct BufferedStackTrace : public StackTrace {
|
|||
friend class FastUnwindTest;
|
||||
};
|
||||
|
||||
#if defined(__s390x__)
|
||||
static const uptr kFrameSize = 160;
|
||||
#elif defined(__s390__)
|
||||
static const uptr kFrameSize = 96;
|
||||
#else
|
||||
static const uptr kFrameSize = 2 * sizeof(uhwptr);
|
||||
#endif
|
||||
|
||||
// Check if given pointer points into allocated stack area.
|
||||
static inline bool IsValidFrame(uptr frame, uptr stack_top, uptr stack_bottom) {
|
||||
return frame > stack_bottom && frame < stack_top - 2 * sizeof (uhwptr);
|
||||
return frame > stack_bottom && frame < stack_top - kFrameSize;
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
|
Loading…
Reference in New Issue