AutoCp
AutoCp copied to clipboard
Bug: ProcessRunnerErr$DeadProcessErr during stress testing
Bug: ProcessRunnerErr$DeadProcessErr during stress testing
Description
When running stress testing, the program throws a ProcessRunnerErr$DeadProcessErr exception, causing the testing process to terminate abnormally.
Error Message
This was not supposed to happen, please file an <a herf="https://github.com/Pushpavel/AutoCp/issues/new/choose">issue</a>
Error message:
null
Stacktrace:
com.github.pushpavel.autocp.tester.errors.ProcessRunnerErr$DeadProcessErr
at com.github.pushpavel.autocp.tester.errors.ProcessRunnerErr$DeadProcessErr.<clinit>(ProcessRunnerErr.kt)
at com.github.pushpavel.autocp.tester.base.ProcessRunner$run$2$deferred$1.invokeSuspend(ProcessRunner.kt:45)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
Screenshot
Steps to Reproduce
- Configure an AutoCp project with a solution file
- Run stress testing
- run the stress testing (may be 1000 or more testcase), the exception will be triggered.
(may be clang++ and macos can reproduce this problem more likely. I didn't encounter this issue previously when using g++-14 on macOS, likely because the binaries compiled by g++-14 ran relatively slower. Recently, I switched to native clang++, which significantly improved execution speed. The much faster process creation and destruction cycle might be triggering this race condition, leading to the error.)
Expected Behavior
The program should do stress testing until it reaches the number I input or find an WA testcase.
Environment
- OS: macOS 24.6.0
- IDE: CLion 2025.1.3
- Programming Language: Cpp
- Plugin Version: AutoCp 0.9.0
Appendix (the gen, brute, and sol cpp)
gen:
/**
* Problem: E. Blackslex and Girls
* Contest: Codeforces Round 1071 (Div. 3)
* Judge: Codeforces
* URL: https://codeforces.com/contest/2179/problem/E
* Created: 2025-12-24 00:50:02
* Author: Gospel_rock
*/
#include <bits/stdc++.h>
#include <ranges>
#define all(vec) vec.begin(),vec.end()
#define lson(o) (o<<1)
#define rson(o) (o<<1|1)
#define SZ(a) ((long long) a.size())
#define debug(var) cerr << #var <<":"<<var<<"\n";
#define cend cerr<<"\n-----------\n"
#define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using DB = double;
using LD = long double;
// using i128 = __int128;
using CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1;
static constexpr ll mod = 998244353; // (ll)1e9+7;
static constexpr double eps = 1e-8;
const double pi = acos(-1.0);
ll lT;
/*
*
*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void Solve() {
// ll N;
// cin >> N;
cout<<1<<"\n";
ll N=uniform_int_distribution<ll>(3,6)(rng);
ll X=uniform_int_distribution<ll>(3,10)(rng),Y=uniform_int_distribution<ll>(3,10)(rng);
cout<<N<<" "<<X<<" "<<Y<<"\n";
for (int i=0;i<N;++i) {
cout<<uniform_int_distribution<ll>(0,1)(rng);
}
cout<<"\n";
for (int i=0;i<N;++i) {
cout<<uniform_int_distribution<ll>(1,4)(rng)<<" ";
}
cout<<"\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// cin >> lT;
// while(lT--)
Solve();
return 0;
}
/*
*/
brute:
/**
* Problem: E. Blackslex and Girls
* Contest: Codeforces Round 1071 (Div. 3)
* Judge: Codeforces
* URL: https://codeforces.com/contest/2179/problem/E
* Created: 2025-12-24 00:38:04
* Author: Gospel_rock
*/
#include <bits/stdc++.h>
#include <ranges>
#define all(vec) vec.begin(),vec.end()
#define lson(o) (o<<1)
#define rson(o) (o<<1|1)
#define SZ(a) ((long long) a.size())
#define debug(var) cerr << #var <<":"<<var<<"\n";
#define cend cerr<<"\n-----------\n"
#define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using DB = double;
using LD = long double;
// using i128 = __int128;
using CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1;
static constexpr ll mod = 998244353; // (ll)1e9+7;
static constexpr double eps = 1e-8;
const double pi = acos(-1.0);
ll lT;
/*
*
*/
struct con_ixy {
ll i;
ll x;
ll y;
bool operator<(const con_ixy &o) const{
if (i!=o.i) return i<o.i;
if (x!=o.x) return x<o.x;
return y<o.y;
}
con_ixy(ll i,ll x,ll y):i(i),x(x),y(y){}
};
void Solve() {
ll N, X, Y;
cin >> N >> X >> Y;
string s;
cin >> s;
// vector<ll> cnt01(2);
// for (int i=0;i<s.size();++i) {
// cnt01[s[i]-'0']++;
// }
vector<ll> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
bool isend=false;
bool ans=false;
set<con_ixy> st_memo;
map<con_ixy,con_ixy> mp_fa;
auto dfs=[&](auto && self,ll step,ll x,ll y) {
if (isend) return;
if (step==N-1) {
if (s[step]=='0' && x>y && x+y>=A[step]) {
isend=true;
ans=true;
}else if (s[step]=='1' && x<y && x+y>=A[step]) {
isend=true;
ans=true;
// con_ixy cur={step,x,y};
}
return;
}
for (int i=0;i<=x;++i) {
for (int j=max(0ll,A[step]-i);j<=y;++j) {
if ((s[step]=='0' && i>j && i+j>=A[step]) || (s[step]=='1' && i<j && i+j>=A[step])) {
auto flag=st_memo.emplace(step+1,x-i,y-j);
if (flag.second) {
// mp_fa[{step+1,x-i,y-j}]={step,x,y};
self(self, step + 1, x - i, y - j);
}
}
}
}
};
dfs(dfs,0,X,Y);
if (ans) {
cout<<"YES\n";
}else {
cout<<"NO\n";
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> lT;
while(lT--)
Solve();
return 0;
}
/*
*/
sol:
/**
* Problem: E. Blackslex and Girls
* Contest: Codeforces Round 1071 (Div. 3)
* Judge: Codeforces
* URL: https://codeforces.com/contest/2179/problem/E
* Created: 2025-12-23 23:17:50
* Author: Gospel_rock
*/
#include <bits/stdc++.h>
#include <ranges>
#define all(vec) vec.begin(),vec.end()
#define lson(o) (o<<1)
#define rson(o) (o<<1|1)
#define SZ(a) ((long long) a.size())
#define debug(var) cerr << #var <<":"<<var<<"\n";
#define cend cerr<<"\n-----------\n"
#define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using DB = double;
using LD = long double;
// using i128 = __int128;
using CD = complex<double>;
static constexpr ll MAXN = (ll) 1e6 + 10, INF = (1ll << 61) - 1;
static constexpr ll mod = 998244353; // (ll)1e9+7;
static constexpr double eps = 1e-8;
const double pi = acos(-1.0);
ll lT;
/*
*
*/
void Solve() {
ll N, X, Y;
cin >> N >> X >> Y;
string s;
cin >> s;
vector<ll> cnt01(2);
for (int i=0;i<s.size();++i) {
cnt01[s[i]-'0']++;
}
vector<ll> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
ll opX=X,opY=Y;
vector<array<ll,2>> suf_cnt_01(N);
// for (int i=N-2;i>=0;--i) {
// suf_cnt_01[i]=suf_cnt_01[i+1];
// suf_cnt_01[i][s[i+1]-'0']++;
// }
for (int i=0;i < N;++i) {
if (s[i]=='0') {
ll consume_x=A[i]/2+1,consume_y=A[i]-consume_x;
if (consume_y<0) consume_y=0;
opX-=consume_x;
opY-=consume_y;
}else if (s[i]=='1'){
ll consume_y=A[i]/2+1,consume_x=A[i]-consume_y;
if (consume_x<0) consume_x=0;
opX-=consume_x;
opY-=consume_y;
}
}
// debug(opX);
// debug(opY);
if (opX<0 && opY<0) {
cout<<"NO\n";
return;
}
auto check_when_opx_opy_big_0=[&]() {
if (opX>=0 && opY>=0) {
if (cnt01[0] && cnt01[1]) {
cout<<"YES\n";
return true;
}
if (cnt01[1]/* && opY>=opX*/) {
ll oopx=opX;
for (int i=0;i<s.size();++i) {
if (s[i]=='1') {
ll consume_y=A[i]/2+1,consume_x=A[i]-consume_y;
if (consume_x<0) consume_x=0;
oopx-=max(0ll,consume_y-consume_x-1);
}
}
if (opY>=oopx) {
cout<<"YES\n";
return true;
}
}
if (cnt01[0] /*&& opX>=opY*/) {
ll oopy=opY;
for (int i=0;i<s.size();++i) {
if (s[i]=='0') {
ll consume_x=A[i]/2+1,consume_y=A[i]-consume_x;
if (consume_y<0) consume_y=0;
oopy-=max(0ll,consume_x-consume_y-1);
}
}
if (opX>=oopy) {
cout<<"YES\n";
return true;
}
}
cout<<"NO\n";
return true;
}
return false;
};
if (check_when_opx_opy_big_0()) {
return;
}
if (opY>=abs(opX)) {
for (int i=0;i<N;++i) {
if (s[i]=='1') {
ll consume_y=A[i]/2+1,consume_x=A[i]-consume_y;
if (consume_x<0) consume_x=0;
ll can_be_replace_with_y=min(consume_x,opY);
opY-=can_be_replace_with_y;
opX+=can_be_replace_with_y;
}
}
if (check_when_opx_opy_big_0()) {
return;
}
}
if (opX>=abs(opY)) {
for (int i=0;i<N;++i) {
if (s[i]=='0') {
ll consume_x=A[i]/2+1,consume_y=A[i]-consume_x;
if (consume_y<0) consume_y=0;
ll can_be_replace_with_x=min(consume_y,opX);
opX-=can_be_replace_with_x;
opY+=can_be_replace_with_x;
}
}
if (check_when_opx_opy_big_0()) {
return;
}
}
cout<<"NO\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> lT;
while (lT--)
Solve();
return 0;
}
/*
1
4 4 5
1101
3 2 1 2
1
4 2 3
0001
1 1 1 1
1
7 11 3
0000000
1 3 1 2 2 1 3
1
3 4 7
111
3 1 2
*/