Commit 6dda8e52 by Abseil Team Committed by Copybara-Service

Always check if the new frame pointer is readable.

Terminate the stack trace if it isn't.

PiperOrigin-RevId: 600839499
Change-Id: I5692fa6cb52c4c8061b4ac14d8fba70f7fbabc52
parent 4676ffa9
...@@ -122,6 +122,13 @@ static void **NextStackFrame(void **old_frame_pointer, const void *uc, ...@@ -122,6 +122,13 @@ static void **NextStackFrame(void **old_frame_pointer, const void *uc,
if (pre_signal_frame_pointer >= old_frame_pointer) { if (pre_signal_frame_pointer >= old_frame_pointer) {
new_frame_pointer = pre_signal_frame_pointer; new_frame_pointer = pre_signal_frame_pointer;
} }
}
#endif
// The frame pointer should be 8-byte aligned.
if ((reinterpret_cast<uintptr_t>(new_frame_pointer) & 7) != 0)
return nullptr;
// Check that alleged frame pointer is actually readable. This is to // Check that alleged frame pointer is actually readable. This is to
// prevent "double fault" in case we hit the first fault due to e.g. // prevent "double fault" in case we hit the first fault due to e.g.
// stack corruption. // stack corruption.
...@@ -129,12 +136,6 @@ static void **NextStackFrame(void **old_frame_pointer, const void *uc, ...@@ -129,12 +136,6 @@ static void **NextStackFrame(void **old_frame_pointer, const void *uc,
new_frame_pointer)) new_frame_pointer))
return nullptr; return nullptr;
} }
}
#endif
// The frame pointer should be 8-byte aligned.
if ((reinterpret_cast<uintptr_t>(new_frame_pointer) & 7) != 0)
return nullptr;
// Only check the size if both frames are in the same stack. // Only check the size if both frames are in the same stack.
if (InsideSignalStack(new_frame_pointer, stack_info) == if (InsideSignalStack(new_frame_pointer, stack_info) ==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment