Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Issue 1354923002: Linux ExceptionHandler: don't allocate the CrashContext on the stack (Closed)

Created:
5 years, 3 months ago by Primiano Tucci (use gerrit)
Modified:
5 years, 3 months ago
CC:
google-breakpad-dev_googlegroups.com, Torne
Base URL:
https://chromium.googlesource.com/breakpad/breakpad.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Linux ExceptionHandler: don't allocate the CrashContext on the stack On Android the size of the alternate stack can be very small (8k). Even if breakpad uses sigaltstack to increase the size of the alternate stack during initialization, that call affects only the main thread. On Android, the libc's pthread initializer reset the sigaltstack to 8k. When entering a signal handler, the kernel typically pushes the context on the alternate stack. On arm64, sizeof(CrashContext) is ~5k, which leaves 3k of usable stack for breakpad. On top of that, breakpad allocates another struct CrashContext on the stack. In the case of Android arm64, then, breakpad ends up using 5k + 5k > 8k of stack, which causes a stack overflow. This got unnoticed in Android L, as the alternate stack didn't have red-zones between them, so breakpad was often happily overflowing onto the next thread's stack. This is not the case anymore [1]. This CL moves the CrashContext into a global variable. It should be safe as the ExceptionHandlers are serialized on a mutex. [1] https://android.googlesource.com/platform/bionic/+/595752f623ae88f7e4193a6e531a0805f1c6c4dc BUG=374 R=mark@chromium.org Committed: https://chromium.googlesource.com/breakpad/breakpad/+/55ba26e52036f745bdaa51fcf4b83a7ef0935f59

Patch Set 1 : #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+27 lines, -15 lines) Patch
M src/client/linux/handler/exception_handler.cc View 3 chunks +27 lines, -15 lines 4 comments Download

Messages

Total messages: 8 (2 generated)
Primiano Tucci (use gerrit)
Mark/Lei, can I ask you take a look to this CL. It's very small but ...
5 years, 3 months ago (2015-09-18 14:29:52 UTC) #3
Tobias Sargeant
I can confirm that this CL results in producing microdumps correctly when WebView-containing processes crash ...
5 years, 3 months ago (2015-09-18 15:10:41 UTC) #4
Mark Mentovai
What if two threads take signals at the same time? https://codereview.chromium.org/1354923002/diff/20001/src/client/linux/handler/exception_handler.cc File src/client/linux/handler/exception_handler.cc (right): https://codereview.chromium.org/1354923002/diff/20001/src/client/linux/handler/exception_handler.cc#newcode249 ...
5 years, 3 months ago (2015-09-18 22:13:20 UTC) #5
Primiano Tucci (use gerrit)
> What if two threads take signals at the same time? Given the mutex |g_handler_stack_mutex| ...
5 years, 3 months ago (2015-09-18 22:22:41 UTC) #6
Mark Mentovai
I don’t know how I missed the mutex literally one line above the change. I ...
5 years, 3 months ago (2015-09-18 22:34:56 UTC) #7
Primiano Tucci (use gerrit)
5 years, 3 months ago (2015-09-22 08:11:30 UTC) #8
Message was sent while issue was closed.
Committed patchset #1 (id:20001) manually as
55ba26e52036f745bdaa51fcf4b83a7ef0935f59 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698