Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions concore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,17 +353,14 @@ class Concore{
ostringstream ss;
ss << infile.rdbuf(); // reading data
ins = ss.str();
retrycount++;
infile.close();
}
else{
retrycount++;
throw 505;
}
}
//observed retry count in C++ from various tests is approx 80.
catch(...){
cout<<"Read error";
cerr << "Error reading " << inpath << port << "/" << name << " (retry " << retry << ")" << endl;
}
retry++;
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

retrycount is a public field used elsewhere in the repo (e.g., scripts print concore.retrycount), but it is no longer incremented during retry attempts here. If the retry count is still intended to be observable, increment retrycount on each failed retry (or remove the field and update callers/docs).

Suggested change
retry++;
retry++;
retrycount++;

Copilot uses AI. Check for mistakes.
}
Expand Down Expand Up @@ -416,16 +413,13 @@ class Concore{
if(shmId_get != -1) {
std::string message(sharedData_get, strnlen(sharedData_get, 256));
ins = message;
retrycount++;
}
else{
retrycount++;
throw 505;
}
}
//observed retry count in C++ from various tests is approx 80.
catch(...){
std::cout << "Read error" << std::endl;
cerr << "Error reading from shared memory port " << port << " name " << name << " (retry " << retry << ")" << endl;
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

retrycount is a public field used elsewhere in the repo (callers print concore.retrycount), but it is no longer incremented during retry attempts in the shared-memory read loop. If this metric is still relied upon, increment it on each failed retry (or remove the field and update callers/docs).

Suggested change
cerr << "Error reading from shared memory port " << port << " name " << name << " (retry " << retry << ")" << endl;
cerr << "Error reading from shared memory port " << port << " name " << name << " (retry " << retry << ")" << endl;
retrycount++;

Copilot uses AI. Check for mistakes.
}
retry++;
}
Expand Down Expand Up @@ -494,14 +488,15 @@ class Concore{
outfile<<val[i]<<',';
outfile<<val[val.size()-1]<<']';
outfile.close();
simtime += delta;
}
else{
throw 505;
}
}

catch(...){
cout<<"skipping +"<<outpath<<port<<" /"<<name;
cerr << "Error writing to " << outpath << port << "/" << name << endl;
}
Comment on lines 498 to 500
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

The new error log in this catch(...) still drops the underlying failure reason. Prefer catching const std::exception& where possible and including e.what() (and/or errno/std::strerror(errno) for I/O failures) so the log is actionable beyond just the path.

Copilot uses AI. Check for mistakes.
}

Expand All @@ -526,7 +521,7 @@ class Concore{
else throw 505;
}
catch(...){
cout<<"skipping +"<<outpath<<port<<" /"<<name;
cerr << "Error writing to " << outpath << port << "/" << name << endl;
}
}

Expand All @@ -549,14 +544,15 @@ class Concore{
outfile<<val[val.size()-1]<<']';
std::string result = outfile.str();
std::strncpy(sharedData_create, result.c_str(), 256 - 1);
simtime += delta;
Comment on lines 545 to +547
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

std::strncpy(sharedData_create, result.c_str(), 256 - 1) does not guarantee null-termination when the source is >= 255 bytes, which can leave stale bytes in shared memory and cause readers to see corrupted/concatenated messages. Explicitly null-terminate the buffer (and consider clearing it before copy) after the strncpy.

Copilot uses AI. Check for mistakes.
}
else{
throw 505;
}
}

catch(...){
cout<<"skipping +"<<outpath<<port<<" /"<<name;
cerr << "Error writing to shared memory port " << port << " name " << name << endl;
}
}

Expand All @@ -577,7 +573,7 @@ class Concore{
else throw 505;
}
catch(...){
cout<<"skipping +"<<outpath<<port<<" /"<<name;
cerr << "Error writing to shared memory port " << port << " name " << name << endl;
}
}

Expand Down
Loading