summaryrefslogtreecommitdiffstats
path: root/debuggerd
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2018-10-30 15:21:10 -0700
committerJosh Gao <jmgao@google.com>2018-10-30 15:33:58 -0700
commit08163cb0321aef9a8a154025649f62b0ae3c43ff (patch)
tree047f94c980f123e2c7d26df9b961d4005b04253e /debuggerd
parentb59a38d34328eb8f297b965bec84233bd7fa6a25 (diff)
downloadsystem_core-08163cb0321aef9a8a154025649f62b0ae3c43ff.tar.gz
system_core-08163cb0321aef9a8a154025649f62b0ae3c43ff.tar.bz2
system_core-08163cb0321aef9a8a154025649f62b0ae3c43ff.zip
debuggerd_fallback: fix fd leak.
Previously, when we received simultaneous dump requests, we were CASing a file descriptor value into a variable, and then failing to close it if the CAS failed. Bug: http://b/118412443 Test: debuggerd_test Change-Id: I075c35a239426002eb9416da3d268c3d1a18e9d2
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/handler/debuggerd_fallback.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/debuggerd/handler/debuggerd_fallback.cpp b/debuggerd/handler/debuggerd_fallback.cpp
index ed7423b37..15c02651c 100644
--- a/debuggerd/handler/debuggerd_fallback.cpp
+++ b/debuggerd/handler/debuggerd_fallback.cpp
@@ -250,11 +250,12 @@ static void trace_handler(siginfo_t* info, ucontext_t* ucontext) {
}
uint64_t expected = pack_thread_fd(-1, -1);
- if (!trace_output.compare_exchange_strong(expected,
- pack_thread_fd(tid, pipe_write.release()))) {
+ int sent_fd = pipe_write.release();
+ if (!trace_output.compare_exchange_strong(expected, pack_thread_fd(tid, sent_fd))) {
auto [tid, fd] = unpack_thread_fd(expected);
async_safe_format_log(ANDROID_LOG_ERROR, "libc",
"thread %d is already outputting to fd %d?", tid, fd);
+ close(sent_fd);
return false;
}