platform_system_core/debuggerd/handler
Josh Gao c531ed6648 debuggerd_fallback: fix race.
A race condition occurs when one thread takes more than a second to get
scheduled to handle the signal we send to ask it to dump its stack.
When this happens, the main thread will continue on, close the fd, and
then ask the next thread to dump, but the slow thread will then wake up
and try to write to the new thread's fd, or trigger an assertion in
__linker_enable_fallback_allocator.

Do a few things to make this less bad:
  - encode both target tid and fd in the shared atomic, so that we know
    who each fd is for
  - switch __linker_enable_fallback_allocator to return success instead
    of aborting, and bail out if it's already in use
  - write to the output fd right when we get to it, instead of doing it
    whenever the dumping code decides to, to reduce the likelihood that
    the timeout expires

Test: debuggerd_test
Change-Id: Ife0f6dae388b601e7f991605f14d7a0274013f6b
2018-02-09 15:35:40 -08:00
..
debuggerd_fallback.cpp debuggerd_fallback: fix race. 2018-02-09 15:35:40 -08:00
debuggerd_fallback_nop.cpp debuggerd_handler: implement missing fallback functionality. 2017-03-09 11:26:05 -08:00
debuggerd_handler.cpp debuggerd_handler: set PR_SET_PTRACER before running crash_dump. 2017-12-27 13:19:31 -08:00