-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support custom threads #415
Conversation
The only failing CI configuration is "Integration Test with kotlinx.coroutines". |
...vm/test/org/jetbrains/kotlinx/lincheck_test/transformation/KotlinStdlibTransformationTest.kt
Outdated
Show resolved
Hide resolved
0ad50bd
to
25c0c45
Compare
@ndkoval while working on this I discovered a few problems, which are probably should be addressed in separate PRs. One of the problems is related to the local objects tracking --- the current implementation does not work correctly with custom threads (see example below and the comment in class Box(var x: Int)
fun test(): Int {
val box = Box() // <- this object is incorrectly classified as a local object
thread {
box.x = 42 // the local object tracker does not detect here that the `box` object,
// stored in the local variable, escapes into another thread;
// thus it will not insert a switch point before accesses to this object fields
}
return box.x
} I would propose that we can address this problem separately in another PR after we merge this one. Alternatively, we can first perform the necessary refactoring of the local objects tracking algorithm in a separate PR, |
bac6712
to
250236c
Compare
Another small bug fix on which this PR relies on: #426 |
8d548c9
to
9a4fdcd
Compare
2428b4f
to
469be4f
Compare
src/jvm/test/resources/expected_logs/obstruction_freedom_synchronized.txt
Outdated
Show resolved
Hide resolved
src/jvm/test/resources/expected_logs/custom_threads_deque_trace.txt
Outdated
Show resolved
Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/LoopDetector.kt
Show resolved
Hide resolved
From what I can see, there is no significant changes in the time of CI builds between this branch and The reason is that in this PR I strive to preserve the old behavior whenever possible, by adding special treatment of
Thus, all the code interacting with |
84be341
to
1f98ee5
Compare
src/jvm/main/org/jetbrains/kotlinx/lincheck/runner/ParallelThreadsRunner.kt
Show resolved
Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/runner/ParallelThreadsRunner.kt
Show resolved
Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/runner/ParallelThreadsRunner.kt
Outdated
Show resolved
Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/runner/ParallelThreadsRunner.kt
Outdated
Show resolved
Hide resolved
src/jvm/main/org/jetbrains/kotlinx/lincheck/transformation/transformers/ThreadTransformer.kt
Show resolved
Hide resolved
val elapsedTime = threadData.spinner.spinWaitTimedUntil(timeoutNano) { | ||
threadData.state == ThreadState.FINISHED || | ||
// TODO: due to limitations of current implementation, | ||
// Lincheck test threads sometime end up in ABORTED state, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, onThreadFinish
is not guaranteed to be called at the end of the thread execution.
This can happen in case of timeout, or in case if some exception was thrown from the code and not properly handled.
To fix this, we will need to modify TestThreadExecutionGenerator
class, to modify the generated bytecode. Wrap the code in try-catch, and put onThreadFinish
into finally
block to guarantee it is always called at the end.
…egy` Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
… blocking Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
…ead group Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
* in preparation of implementing ignored sections for custom threads Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
* do not switch to a thread awaiting thread join until the awaited thread finishes * print the awaited thread id in the thread switch trace point Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
…tion Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
…ork` injection Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
… of ignored section check) Signed-off-by: Evgeniy Moiseenko <[email protected]>
… of ignored section check) Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
… `utils/Ensure.kt` Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
…criptor` class Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
Signed-off-by: Evgeniy Moiseenko <[email protected]>
No description provided.