From 5370685fa3db819a7593ac909d91895d51e46559 Mon Sep 17 00:00:00 2001 From: Maksim Pelevin Date: Wed, 11 Jan 2023 16:21:45 +0300 Subject: [PATCH 1/4] Clarify coroutines usage --- .../src/main/kotlin/org/utbot/contest/Contest.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt index 7c915bf600..9f85a39364 100644 --- a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt +++ b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt @@ -293,7 +293,7 @@ fun runGeneration( UtSettings.fuzzingTimeoutInMillis = (budgetForMethod * fuzzingRatio).toLong() //start controller that will activate symbolic execution - GlobalScope.launch(currentContext) { + launch(currentContext) { delay(budgetForSymbolicExecution) if (methodJob.isActive) { @@ -366,8 +366,7 @@ fun runGeneration( controller.job = job //don't start other methods while last method still in progress - while (job.isActive) - yield() + job.join() remainingMethodsCount-- } From cd2e302a0feb1c9320ff23b54ce600a2e2fb32b6 Mon Sep 17 00:00:00 2001 From: Maksim Pelevin Date: Wed, 11 Jan 2023 16:22:23 +0300 Subject: [PATCH 2/4] Do not force reload soot in Contest --- .../src/main/kotlin/org/utbot/contest/Contest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt index 9f85a39364..190c980703 100644 --- a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt +++ b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt @@ -199,7 +199,7 @@ fun runGeneration( setOptions() //will not be executed in real contest logger.info().bracket("warmup: 1st optional soot initialization and executor warmup (not to be counted in time budget)") { - TestCaseGenerator(listOf(cut.classfileDir.toPath()), classpathString, dependencyPath, JdkInfoService.provide()) + TestCaseGenerator(listOf(cut.classfileDir.toPath()), classpathString, dependencyPath, JdkInfoService.provide(), forceSootReload = false) } logger.info().bracket("warmup (first): kotlin reflection :: init") { prepareClass(ConcreteExecutorPool::class.java, "") @@ -241,7 +241,7 @@ fun runGeneration( val testCaseGenerator = logger.info().bracket("2nd optional soot initialization") { - TestCaseGenerator(listOf(cut.classfileDir.toPath()), classpathString, dependencyPath, JdkInfoService.provide()) + TestCaseGenerator(listOf(cut.classfileDir.toPath()), classpathString, dependencyPath, JdkInfoService.provide(), forceSootReload = false) } From 3f7913246e5c9e2e9df464c1453bfc84fd411a40 Mon Sep 17 00:00:00 2001 From: Maksim Pelevin Date: Thu, 12 Jan 2023 11:04:10 +0300 Subject: [PATCH 3/4] Return GlobalScope call to prevent hangs --- .../src/main/kotlin/org/utbot/contest/Contest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt index 190c980703..e4c925593d 100644 --- a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt +++ b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt @@ -293,7 +293,7 @@ fun runGeneration( UtSettings.fuzzingTimeoutInMillis = (budgetForMethod * fuzzingRatio).toLong() //start controller that will activate symbolic execution - launch(currentContext) { + GlobalScope.launch(currentContext) { delay(budgetForSymbolicExecution) if (methodJob.isActive) { From cc2181cedc72b6cfd95d4bbfd8fcde20fccf4ba9 Mon Sep 17 00:00:00 2001 From: Maksim Pelevin Date: Thu, 12 Jan 2023 11:55:39 +0300 Subject: [PATCH 4/4] Catch exceptions from the job.join --- .../src/main/kotlin/org/utbot/contest/Contest.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt index e4c925593d..c4f98c5eb6 100644 --- a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt +++ b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt @@ -366,7 +366,11 @@ fun runGeneration( controller.job = job //don't start other methods while last method still in progress - job.join() + try { + job.join() + } catch (t: Throwable) { + logger.error(t) { "Internal job error" } + } remainingMethodsCount-- }