Skip to content

fix: segfault in OpenSwathWorkflow with use_consensus=false - #9143

Merged
timosachsenberg merged 2 commits into
developfrom
fix/use-consensus-false-segfault
Apr 13, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
fix/use-consensus-false-segfault

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #9138 — OpenSwathWorkflow segfaults when use_consensus=false with detecting=1 and quantifying=1.

  • Root cause: In non-consensus mode, PeakIntegrator::integratePeak produces hull_points of different sizes per transition (each clipped to its own peak boundaries). These become intensity vectors for Scoring::calculateCrossCorrelation, which assumes equal-sized vectors and reads past the end of the shorter one via Eigen::Map.
  • Fix: After integratePeak, override hull_points with the full resampled chromatogram (always master_peak_container-sized) in non-consensus mode. Area, height, and apex position remain computed with per-transition boundaries (unchanged behavior).
  • Also explains: Case 1 from the issue (detecting=1, quantifying=0 → empty results) is expected behavior — at least one quantifying transition is required for non-zero feature intensity.

Bug has been latent since the use_consensus=false feature was introduced in April 2018.

Test plan

  • MRMTransitionGroupPicker_test passes (existing values unchanged)
  • TOPP MRMTransitionGroupPicker integration tests pass (FuzzyDiff output match)
  • New regression test verifies hull_points are equal-sized across transitions in non-consensus mode
  • CI

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Resolved an issue where peak boundaries could be incorrect when consensus mode was off; peak intensity samples are now used to build peak shapes for accurate chromatogram analysis.
    • Added checks to ensure peak boundary sizes are consistent across related transitions and restored stability for cross-correlation scoring paths.

When use_consensus=false, each transition gets individual peak boundaries
from pickApex. PeakIntegrator::integratePeak produces hull_points of
different sizes per transition (only points within local boundaries).
These hull_points become intensity vectors for cross-correlation scoring
in MRMScoring::initializeXCorrMatrix. Scoring::calculateCrossCorrelation
assumes equal-sized vectors and reads past the end of the shorter one
via Eigen::Map, causing a segfault.

Fix: after integratePeak, override hull_points with the full resampled
chromatogram (always master_peak_container-sized) in non-consensus mode.
This preserves correct per-transition area/height/apex while ensuring
equal-sized intensity vectors for scoring.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Peak construction now conditionally replaces each feature's convex-hull points with intensity samples from the full resampled chromatogram when use_consensus_ == false, applied in both fragment and precursor peak-picking paths. Tests were extended to assert non-empty, equal-sized hull point sets across transitions and to exercise x-correlation scoring.

Changes

Cohort / File(s) Summary
Peak Hull Point Override
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/MRMTransitionGroupPicker.h
When use_consensus_ is false, clear PeakIntegrator::PeakArea::hull_points and repopulate with (position,intensity) samples from the full resampled chromatogram in both fragment and precursor picking code paths before setting the output hull.
Tests — hull points & scoring
src/tests/class_tests/openms/source/MRMTransitionGroupPicker_test.cpp
Adds assertions that convex hull point counts for transitions "1","2","3" are equal and >0 when use_consensus=false; wraps produced MRMFeature for OpenSwath scoring and asserts finite coelution/shape x-correlation scores to exercise the previously crashing path.

Poem

🐰 I hopped through chromatogram lanes at night,
Hull points scattered, not quite right,
I stitched each peak with sampled light,
Now transitions align, snug and tight,
Hooray—no crash, the scores take flight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies a segfault bug fix related to OpenSwathWorkflow with use_consensus=false, matching the main change in the code.
Linked Issues check ✅ Passed The code changes implement the fix for issue #9138 by overriding hull_points with full resampled chromatogram data in non-consensus mode, ensuring equal-sized intensity vectors for scoring and preventing the segfault.
Out of Scope Changes check ✅ Passed All changes are within scope: hull_points override logic in MRMTransitionGroupPicker for non-consensus mode and regression test verifying equal-sized hull_points vectors in scoring path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/use-consensus-false-segfault

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.

The hull_points size check verifies the data structure, but the actual
crash occurred in MRMScoring::initializeXCorrMatrix when cross-
correlating different-sized intensity vectors. This test wraps the
non-consensus features in MRMFeatureOpenMS and runs the full
cross-correlation scoring — the exact code path that segfaulted.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/tests/class_tests/openms/source/MRMTransitionGroupPicker_test.cpp`:
- Around line 475-484: Replace the owning raw pointer usage with a
stack-allocated MRMFeatureOpenMS and pass its address to initializeXCorrMatrix:
instead of allocating imrmfeature via new and deleting it, create a local
MRMFeatureOpenMS instance (e.g., MRMFeatureOpenMS imrmfeature(mrmfeature)) and
call mrmscore.initializeXCorrMatrix(&imrmfeature, native_ids); then call
mrmscore.calcXcorrCoelutionScore() and mrmscore.calcXcorrShapeScore() as before
and remove the delete imrmfeature; line. This keeps the same behavior while
using RAII and avoiding manual delete.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ad7d94b-8ec0-4f74-b45b-c67a476d0b48

📥 Commits

Reviewing files that changed from the base of the PR and between 856f63e and 838acad.

📒 Files selected for processing (1)
  • src/tests/class_tests/openms/source/MRMTransitionGroupPicker_test.cpp

@timosachsenberg
timosachsenberg merged commit 5921c32 into develop Apr 13, 2026
41 checks passed
@timosachsenberg
timosachsenberg deleted the fix/use-consensus-false-segfault branch April 13, 2026 14:07
@jcharkow

Copy link
Copy Markdown
Collaborator

Looks reasonable. I never use consensus = false so it makes sense it was latent for a long time.

github-actions Bot pushed a commit that referenced this pull request Apr 14, 2026
Add two missing changelog entries for commits after the last sync (#9140):
- #9139: Transparent .zip decompression for XML formats and Bruker .d
- #9143: Fix segfault in OpenSwathWorkflow with use_consensus=false

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Apr 14, 2026
Add two missing changelog entries for commits after the last sync (#9140):
- #9139: Transparent .zip decompression for XML formats and Bruker .d
- #9143: Fix segfault in OpenSwathWorkflow with use_consensus=false

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.

OpenSwathWorkflow: problem with use_consensus=false when detecting=1 and quantifying

2 participants