Hello Michael Smith, Impala Public Jenkins,

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24033

to look at the new patch set (#3).

Change subject: IMPALA-14325: Fix ASAN heap-use-after-free in background threads
......................................................................

IMPALA-14325: Fix ASAN heap-use-after-free in background threads

Fixes IMPALA-14325 and other similar ASAN issues.

Threads running a function with an infinite loop
(e.g. LogMaintenanceThread) can cause ASAN heap-use-after-free
errors when exiting, if they try to read a resource already
freed by a static global variable.

This sometimes happens in flaky tests, but it happens rarely,
depending on how much sleep is remaining when the exit happens.
Also, it only happens with tests that exit in a non-graceful way,
e.g. by calling stdlib's exit.

To fix this issue, the following was changed:
1. The definition of the thread's static unique_ptr variables were
   moved inside function scope, so that their initialization happens
   after (and their destruction before) those of global static objects.
2. The boost threads are interrupted in Impala::Thread's destructor.
   This causes them to exit the loop upon the next sleep, (if they
   sleeping, interrupt wakes them up first), throwing an exception
   which is caught in SuperviseThread.
3. Threads use boost::this_thread::sleep for sleeping, so that they
   stop the next time they would go to sleep (or if already sleeping,
   woken up and stopped).

Testing:
- before the patch, an ASAN heap-use-after-free can be consistently
  reproduced by removing the sleep in LogMaintenanceThread
- after the patch, the heap-use-after-free didn't reproduce

Change-Id: I97188e5ca2ace960c5db5cb44af44f42255902e8
---
M be/src/common/init.cc
M be/src/util/thread.cc
M be/src/util/thread.h
3 files changed, 37 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/33/24033/3
--
To view, visit http://gerrit.cloudera.org:8080/24033
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I97188e5ca2ace960c5db5cb44af44f42255902e8
Gerrit-Change-Number: 24033
Gerrit-PatchSet: 3
Gerrit-Owner: Balazs Hevele <[email protected]>
Gerrit-Reviewer: Balazs Hevele <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Michael Smith <[email protected]>

Reply via email to