Fix monitor verification.
An earlier change inadvertently disabled the basic register type check
when the fancier checks were disabled. This restores the type check,
and replaces a "TODO: add an assert" with an actual assert.
Bug 3246598.
(cherry-pick from dalvik-dev)
Change-Id: Iddfb33d2a3f0c03f5a06c3f6e4a47644ca640736
diff --git a/vm/analysis/CodeVerify.c b/vm/analysis/CodeVerify.c
index e1465b8..ba641f3 100644
--- a/vm/analysis/CodeVerify.c
+++ b/vm/analysis/CodeVerify.c
@@ -3295,19 +3295,18 @@
void handleMonitorEnter(RegisterLine* workLine, u4 regIdx, u4 insnIdx,
VerifyError* pFailure)
{
- /*
- * This should only be true if structured lock checking is disabled.
- * TODO: assert that this is the case
- */
- if (workLine->monitorEntries == NULL)
- return;
-
if (!regTypeIsReference(getRegisterType(workLine, regIdx))) {
LOG_VFY("VFY: monitor-enter on non-object\n");
*pFailure = VERIFY_ERROR_GENERIC;
return;
}
+ if (workLine->monitorEntries == NULL) {
+ /* should only be true if monitor verification is disabled */
+ assert(!gDvm.monitorVerification);
+ return;
+ }
+
if (workLine->monitorStackTop == kMaxMonitorStackDepth) {
LOG_VFY("VFY: monitor-enter stack overflow (%d)\n",
kMaxMonitorStackDepth);
@@ -3329,19 +3328,18 @@
void handleMonitorExit(RegisterLine* workLine, u4 regIdx, u4 insnIdx,
VerifyError* pFailure)
{
- /*
- * This should only be true if structured lock checking is disabled.
- * TODO: assert that this is the case
- */
- if (workLine->monitorEntries == NULL)
- return;
-
if (!regTypeIsReference(getRegisterType(workLine, regIdx))) {
LOG_VFY("VFY: monitor-exit on non-object\n");
*pFailure = VERIFY_ERROR_GENERIC;
return;
}
+ if (workLine->monitorEntries == NULL) {
+ /* should only be true if monitor verification is disabled */
+ assert(!gDvm.monitorVerification);
+ return;
+ }
+
if (workLine->monitorStackTop == 0) {
LOG_VFY("VFY: monitor-exit stack underflow\n");
*pFailure = VERIFY_ERROR_GENERIC;