Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spin locks detection enhancements #228

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from

Conversation

avpotapov00
Copy link
Collaborator

@avpotapov00 avpotapov00 commented Aug 2, 2023

Closes #219 #218 and adds recursive spin-locks support.

Subtasks:

  • Rebase on develop with javaagent 2d
  • Code review 3d

@avpotapov00 avpotapov00 self-assigned this Aug 2, 2023
@avpotapov00 avpotapov00 changed the base branch from master to develop August 2, 2023 22:53
Aleksandr.Potapov added 4 commits August 3, 2023 00:55
…on-enhancements

# Conflicts:
#	src/jvm/main/org/jetbrains/kotlinx/lincheck/runner/InvocationResult.kt
#	src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/InterleavingSequenceTrackableSet.kt
#	src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/ManagedStrategy.kt
#	src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/modelchecking/ModelCheckingStrategy.kt
#	src/jvm/test/org/jetbrains/kotlinx/lincheck_test/representation/SpinlockEventsCutTests.kt
#	src/jvm/test/resources/expected_logs/switch_in_the_middle_of_spin_cycle_causes_error.txt
Copy link
Collaborator

@ndkoval ndkoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an intermediate review. I need to switch to java agents now; after that, I'll finish the review.

@@ -52,6 +52,7 @@ kotlin {
api("org.ow2.asm:asm-commons:$asmVersion")
api("org.ow2.asm:asm-util:$asmVersion")
api("org.reflections:reflections:$reflectionsVersion")
api("net.sf.trove4j:trove4j:3.0.3")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please repackage it to org.jetbrains.kotlinx.lincheck


package org.jetbrains.kotlinx.lincheck.strategy.managed;

public class TrackMethodsFlagHolder {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrite to Kotlin


package org.jetbrains.kotlinx.lincheck.strategy.managed;

public class TrackMethodsFlagHolder {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use it only when detecting spin locks?

@@ -84,7 +84,8 @@ private static boolean doNotTransform(String className) {
className.equals(kotlinx.coroutines.CoroutineContextKt.class.getName()) ||
className.equals(kotlinx.coroutines.CancellableContinuation.class.getName()) ||
className.equals(kotlinx.coroutines.CoroutineExceptionHandler.class.getName()) ||
className.equals(kotlinx.coroutines.CoroutineDispatcher.class.getName());
className.equals(kotlinx.coroutines.CoroutineDispatcher.class.getName()) ||
className.equals(TrackMethodsFlagHolder.class.getName());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to other Lincheck classes, it should not be transformed by default

@@ -252,6 +260,7 @@ internal class ModelCheckingStrategy(
}

fun rollbackAfterSpinCycleFound() {
lastNotInitializedNode = initialLastNotInitializedNode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to another bug?

): InterleavingHistoryNode {
check(executions >= executionsBeforeCycle)
check(executions >= executionsBeforeCycle) { "?" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace "?" with a meaningful message

@@ -241,7 +256,8 @@ internal class InterleavingSequenceTrackableSet {
fun mergeBranch(newChain: List<InterleavingHistoryNode>, startIndex: Int, executionsCountedEarlier: Int) {
if (startIndex > newChain.lastIndex) return
val firstNewNode = newChain[startIndex]
val firstNewNodeExecutions = (firstNewNode.executions + firstNewNode.spinCyclePeriod) - executionsCountedEarlier
val firstNewNodeExecutions =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the formatting

@@ -263,7 +279,8 @@ internal class InterleavingSequenceTrackableSet {
transitions = transitions,
cyclePeriod = cyclePeriod,
cycleOccurred = cycleOccurred,
cycleLocationsHash = cycleLocationsHash
cycleLocationsHash = cycleLocationsHash,
executionsBeforeSpinCycleWithAdditionalEvents = executionsBeforeSpinCycleWithAdditionalEvents
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorten the parameter name

@@ -424,6 +444,8 @@ internal class InterleavingSequenceTrackableSet {
it.cycleOccurred && executionsCount == it.executions
} ?: false

val executionsBeforeSpinCycleWithAdditionalEvents: Int get() = currentNode!!.executionsBeforeSpinCycleWithAdditionalEvents
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document

} else CycleInfo(
minLastPositionNotRelatedToCycle + 1,
targetCycleLength
) // number of prefix elements with first cycle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the comment in the correct place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants