Commit 3a84e31b authored by Mathieu Chartier's avatar Mathieu Chartier
Browse files

Allocate interrupted exception before re-acquiring lock

Allocating the monitor exception after acquiring the lock can cause
a deadlock in the following scenario:

Reference queue daemon interrupted from wait() on
ReferenceQueue.class. Tries to allocate exception and starts a GC
that blocks on WaitForGcToComplete.

Some other thread is already doing a GC, and tries to enqueue the
cleared refereneces. This deadlocks trying to lock Reference.class
in ReferenceQueue.add.

Bug: 27508829

(cherry picked from commit daed5d81)

Change-Id: Ibdc2769077976545385d8c6ecc5bf26316eb70a1
parent d0562a32
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment