add bulletproofing for the case that waveform data come before the first channel header word #121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR _Fixes #120 _
The method decode_data in NevisTPCUtilities.cc is not guarded against the case where data that are interpreted as ADC data (either with type kADC or kADCHuffman) come before the first kChannelHeader word in a fragment. Such data are corrupt, as we do not know what channel they correspond to, and the currentWaveformPtr is uninitialized, causing a segfault. This was spotted trying to decode data from run 18101, taken January 7, 2025.
Related Repository Branches
No related branches, just this one.
Testing details
Bug reproduction before this PR:
gdb --args lar -c run_decoders_job.fcl root://fndca1.fnal.gov:1094//pnfs/fnal.gov/usr/sbnd/archive/sbn/sbn_nd/data/raw/unknown/v1_10_04/sbnd_daq_v1_10_04/daq/00/01/81/01/data_EventBuilder1_art1_run18101_1_strmUnknown_20250107T214345.root
Program received signal SIGSEGV, Segmentation fault.
sbndaq::NevisTPCDecoder::decode_data (this=this@entry=0x7ffffffdd0b0, data_ptr=, n_words=n_words@entry=40593, wvfm_map=...)
at /home/trj/saut/triggerdecoder/sbndc4/srcs/sbndaq_artdaq_core/sbndaq-artdaq-core/Overlays/SBND/NevisTPC/NevisTPCUtilities.cc:97
97 currentWaveformPtr->emplace_back( currentWaveformPtr->back() + differences[i_diff - 1] );
Decoding this file succeeds with this PR, but the data do look corrupt from run 18101 Lots of invalid fragment handles, duplicate
channel headers, mismatching headers and trailers, and the event displays look choppy. But the decoder succeeds.
same story with data_EventBuilder3_art1_run18101_1_strmUnknown_20250107T214346.root
I also tested a normal file to make sure the decoding wasn't broken by this PR:
data_EventBuilder5_art1_run18214_100_strmBNBZeroBias_20250205T145349.root
decoded just fine.