Unlock the monitor mutex before destroying it. This resolves an issue
with simulator builds where, unlike bionic, libc checks whether a
mutex is in the unlocked state before a destroy and returns EBUSY if
the check fails. Until similar checks are added to bionic we now do a
trylock, unlock sequence in the assert statements so as not to confuse
the simulator build.
Change-Id: Iafa3c52edddb17b9a8a2c648c5fd3a58d5d77988
diff --git a/vm/Sync.c b/vm/Sync.c
index c00a630..c9624d0 100644
--- a/vm/Sync.c
+++ b/vm/Sync.c
@@ -310,7 +310,8 @@
* the object, in which case we've got some bad
* native code somewhere.
*/
- assert(dvmTryLockMutex(&mon->lock) == 0);
+ assert(pthread_mutex_trylock(&mon->lock) == 0);
+ assert(pthread_mutex_unlock(&mon->lock) == 0);
dvmDestroyMutex(&mon->lock);
#ifdef WITH_DEADLOCK_PREDICTION
expandObjClear(&mon->historyChildren);