Skip to content

Fix combiner crash#4322

Merged
pinkenburg merged 3 commits into
sPHENIX-Collaboration:masterfrom
pinkenburg:fix-combiner-crash
Jun 27, 2026
Merged

Fix combiner crash#4322
pinkenburg merged 3 commits into
sPHENIX-Collaboration:masterfrom
pinkenburg:fix-combiner-crash

Conversation

@pinkenburg

@pinkenburg pinkenburg commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Types of changes

  • [X ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work for users)
  • Requiring change in macros repository (Please provide links to the macros pull request in the last section)
  • I am a member of GitHub organization of sPHENIX Collaboration, EIC, or ECCE (contact Chris Pinkenburg to join)

What kind of change does this PR introduce? (Bug fix, feature, ...)

We have a few raw data files which do not contain data events (daq problem), only the begin and end run event. The event combiner did not expect this and segfaulted somewhere deep in its guts. This PR catches this particular failure and quits gracefully with an error.
A consequence of this is that the runnumber rc flag is not set which triggers a warning and stacktrace when Fun4All calls the EndRun with the runnumber rc flag. Now Fun4All checks if this flag exists and - if not - will not call EndRun for registered modules. This should take care of misleading printouts in some of our logfiles

TODOs (if applicable)

Links to other PRs in macros and calibration repositories (if applicable)

This PR fixes a crash in the raw-data event combiner (coresoftware) that occurred when an input file contains only begin/end run events (no data events), caused by a DAQ issue. It also prevents follow-on noise where the RUNNUMBER rc flag was not set, which could lead Fun4All to attempt EndRun in an invalid state.

Key changes:

  • SingleTriggeredInput::FillPool: added an early guard to detect “begin/end-only” raw files (no data packets), log the condition, call AllDone(1), and exit cleanly instead of continuing into a failing combiner path.
  • Fun4AllServer::End: added a guard so EndRun() is called only if recoConsts contains the RUNNUMBER integer flag; if missing, it skips EndRun() for registered modules to reduce misleading warnings/stack traces.
  • Build/link cleanup: removed -lboost_filesystem from offline/framework/fun4all/Makefile.am and simulation/g4simulation/g4main/Makefile.am library link lists.

Potential risk areas:

  • Behavior/logging changes in the failure path for malformed/incomplete raw files (different exit timing and error messaging).
  • Potential build/link behavior changes from removing boost_filesystem linkage (should be harmless if no longer required, but verify in your build environment).

Possible future improvements:

  • Add a targeted regression test for begin/end-only raw inputs to ensure graceful termination and correct end-of-run handling.
  • Improve diagnostics to surface why the raw input produced zero data events (e.g., upstream DAQ metadata or packet counters).
  • Audit other end-of-run/teardown paths for similar “missing rc flag” assumptions.

AI can make mistakes—please use best judgment when reading this summary.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fb2ada20-3429-466e-963e-4f942c762b4a

📥 Commits

Reviewing files that changed from the base of the PR and between 9171015 and 7c2cf32.

📒 Files selected for processing (2)
  • offline/framework/fun4all/Makefile.am
  • simulation/g4simulation/g4main/Makefile.am
💤 Files with no reviewable changes (2)
  • offline/framework/fun4all/Makefile.am
  • simulation/g4simulation/g4main/Makefile.am

📝 Walkthrough

Walkthrough

Fun4AllServer::End now skips EndRun when RUNNUMBER is unset. SingleTriggeredInput now returns early for input files with no data events and adds a verbose deque-size message in ReadEvent. Two Makefile link lists also drop boost_filesystem.

Changes

Fun4All end-of-run guard

Layer / File(s) Summary
Guard EndRun() call
offline/framework/fun4all/Fun4AllServer.cc
Fun4AllServer::End() checks recoConsts for RUNNUMBER, calls EndRun() only when it exists, and logs when it is absent.

SingleTriggeredInput input handling

Layer / File(s) Summary
Handle empty raw input
offline/framework/fun4allraw/SingleTriggeredInput.cc
FillPool() now logs and calls AllDone(1) when FillEventVector() fails and m_PacketEventDeque is empty.
Log deque size during verbose reads
offline/framework/fun4allraw/SingleTriggeredInput.cc
ReadEvent() now prints the current packet deque size inside the Verbosity() > 1 block before continuing event processing.

Link dependency cleanup

Layer / File(s) Summary
Remove boost filesystem linkage
offline/framework/fun4all/Makefile.am, simulation/g4simulation/g4main/Makefile.am
Both link lists remove -lboost_filesystem while keeping the remaining libraries unchanged.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 29778abb-c420-49eb-aa61-abbd9d4ac5b8

📥 Commits

Reviewing files that changed from the base of the PR and between c89585e and 9171015.

📒 Files selected for processing (2)
  • offline/framework/fun4all/Fun4AllServer.cc
  • offline/framework/fun4allraw/SingleTriggeredInput.cc

Comment on lines +1108 to +1110
if (rc->FlagExist("RUNNUMBER"))
{
EndRun(rc->get_IntFlag("RUNNUMBER")); // call SubsysReco EndRun methods for current run

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use an int-specific RUNNUMBER check here.

PHFlag::FlagExist() is type-agnostic, so this branch is still unsafe: it returns true if RUNNUMBER exists as a string/float/etc., and get_IntFlag("RUNNUMBER") then emits the same error/stack trace and falls back to 0. That means the new guard does not fully satisfy the PHFlag contract and can still call EndRun(0) in a mistyped-flag scenario. Please gate this on integer-flag existence specifically, or otherwise avoid get_IntFlag() unless the flag is known to be an int.

Comment on lines 731 to +739
int eventvectorsize = FillEventVector();
// this seems a unique signature for raw data files which only contain the
// begin and end run event but no data events. FillEventVector() returns -1
// and since no events were read the m_PacketEventDeque is empty
if (eventvectorsize < 0 && m_PacketEventDeque.empty())
{
std::cout << Name() << ": No data Events in input file " << FileName() << std::endl;
AllDone(1);
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

The no-data-file guard never fires once packet keys have been seeded.

FillEventVector() touches m_PacketEventDeque[pid] before any data event is accepted, so on the begin/end-only input this map is typically non-empty with only empty deques. That makes m_PacketEventDeque.empty() false here, so AllDone(1) is skipped and Fun4AllTriggeredInputManager::run() still proceeds past FillPool() instead of taking the graceful empty-input exit this PR is adding.

Suggested fix
     int eventvectorsize = FillEventVector();
-    if (eventvectorsize < 0 && m_PacketEventDeque.empty())
+    const bool no_packet_events = std::all_of(
+        m_PacketEventDeque.begin(), m_PacketEventDeque.end(),
+        [](const auto& entry) { return entry.second.empty(); });
+    if (eventvectorsize < 0 && no_packet_events)
     {
       std::cout << Name() << ": No data Events in input file " << FileName() << std::endl;
       AllDone(1);
       return;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
int eventvectorsize = FillEventVector();
// this seems a unique signature for raw data files which only contain the
// begin and end run event but no data events. FillEventVector() returns -1
// and since no events were read the m_PacketEventDeque is empty
if (eventvectorsize < 0 && m_PacketEventDeque.empty())
{
std::cout << Name() << ": No data Events in input file " << FileName() << std::endl;
AllDone(1);
return;
int eventvectorsize = FillEventVector();
// this seems a unique signature for raw data files which only contain the
// begin and end run event but no data events. FillEventVector() returns -1
// and since no events were read the m_PacketEventDeque is empty
const bool no_packet_events = std::all_of(
m_PacketEventDeque.begin(), m_PacketEventDeque.end(),
[](const auto& entry) { return entry.second.empty(); });
if (eventvectorsize < 0 && no_packet_events)
{
std::cout << Name() << ": No data Events in input file " << FileName() << std::endl;
AllDone(1);
return;

@sphenix-jenkins-ci

Copy link
Copy Markdown

Build & test report

Report for commit 9171015afe8801b42ed748b6c1a9adec3ba42ecd:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@sphenix-jenkins-ci

Copy link
Copy Markdown

Build & test report

Report for commit 7c2cf3216d31715150d8ef890ba97669b88f8a79:
Jenkins passed


Automatically generated by sPHENIX Jenkins continuous integration
sPHENIX             jenkins.io

@pinkenburg pinkenburg merged commit 565853f into sPHENIX-Collaboration:master Jun 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant