Skip to content

Commit

Permalink
fix more deadlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
aoli-al committed Apr 24, 2024
1 parent 04aaeeb commit 08f8d7e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
8 changes: 6 additions & 2 deletions core/src/main/kotlin/cmu/pasta/fray/core/RuntimeDelegate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class RuntimeDelegate : Delegate() {
}
}

override fun onLockTryLockDone(l: Lock) {
skipFunctionEntered.set(skipFunctionEntered.get() - 1)
}

override fun onLockLock(l: Lock) {
if (checkEntered()) {
skipFunctionEntered.set(1 + skipFunctionEntered.get())
Expand All @@ -135,8 +139,8 @@ class RuntimeDelegate : Delegate() {
try {
GlobalContext.lockLock(l, false)
} finally {
entered.set(false)
skipFunctionEntered.set(skipFunctionEntered.get() + 1)
entered.set(false)
}
}

Expand Down Expand Up @@ -372,8 +376,8 @@ class RuntimeDelegate : Delegate() {
try {
GlobalContext.semaphoreAcquire(sem, permits, true, true)
} finally {
entered.set(false)
skipFunctionEntered.set(skipFunctionEntered.get() + 1)
entered.set(false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class LockInstrumenter(cv: ClassVisitor) :
exceptions: Array<out String>?
): MethodVisitor {
if (name == "tryLock") {
return MethodEnterVisitor(mv, Runtime::onLockTryLock, access, name, descriptor, true, false)
val eMv =
MethodEnterVisitor(mv, Runtime::onLockTryLock, access, name, descriptor, true, false)
return MethodExitVisitor(
eMv, Runtime::onLockTryLockDone, access, name, descriptor, true, false, true)
}
if (name == "lock" || name == "lockInterruptibly") {
val eMv =
Expand Down
1 change: 0 additions & 1 deletion integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ tasks.test {
executable("${jdk.layout.buildDirectory.get().asFile}/java-inst/bin/java")
jvmArgs("-agentpath:$agentPath")
jvmArgs("-javaagent:${instrumentation.layout.buildDirectory.get().asFile}/libs/${instrumentation.name}-${instrumentation.version}-all.jar")
jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005")
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package cmu.pasta.fray.it.lincheck;

import cmu.pasta.fray.core.scheduler.POSScheduler;
import cmu.pasta.fray.core.scheduler.*;
import cmu.pasta.fray.it.IntegrationTestRunner;
import cmu.pasta.fray.it.logicalorderingavl.LogicalOrderingAVL;
import org.junit.jupiter.api.Test;

import java.util.Random;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class LogicalOrderingAVLTest extends IntegrationTestRunner {
Expand All @@ -20,7 +18,7 @@ public void testConcurrentInsertRemove() {
throw new RuntimeException(e);
}
return null;
}, new POSScheduler(new Random()), 10000);
}, new PCTScheduler(new ControlledRandom(), 3), 50000);
assertTrue(res.contains("Error found"));
}

Expand Down
4 changes: 0 additions & 4 deletions run.sh

This file was deleted.

4 changes: 4 additions & 0 deletions runtime/src/main/java/cmu/pasta/fray/runtime/Delegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ public void onObjectNotifyAll(Object o) {
public void onLockTryLock(Lock l) {
}

public void onLockTryLockDone(Lock l) {
}

public void onLockLock(Lock l) {
}

public void onLockLockInterruptibly(Lock l) {
}

Expand Down
6 changes: 5 additions & 1 deletion runtime/src/main/java/cmu/pasta/fray/runtime/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public static void onLockTryLock(Lock l) {
DELEGATE.onLockTryLock(l);
}

public static void onLockTryLockDone(Lock l) {
DELEGATE.onLockTryLockDone(l);
}

public static void onLockLock(Lock l) {
DELEGATE.onLockLock(l);
}
Expand Down Expand Up @@ -245,7 +249,7 @@ public static void onSemaphoreAcquirePermitsUninterruptibly(Semaphore sem, int p
DELEGATE.onSemaphoreAcquireUninterruptibly(sem, permits);
}

public static void onLockLockInterruptibly(ReentrantLock l) {
public static void onLockLockInterruptibly(Lock l) {
DELEGATE.onLockLockInterruptibly(l);
}

Expand Down

0 comments on commit 08f8d7e

Please sign in to comment.