Skip to content

fix(Calorimeter): avoid std::format to work around libstdc++ ABI clash#27

Closed
olantwin wants to merge 3 commits into
mainfrom
fix/overlapcheck-segfault
Closed

fix(Calorimeter): avoid std::format to work around libstdc++ ABI clash#27
olantwin wants to merge 3 commits into
mainfrom
fix/overlapcheck-segfault

Conversation

@olantwin
Copy link
Copy Markdown
Contributor

@olantwin olantwin commented Jun 5, 2026

Summary

Fixes the OverlapCheck segfault that #26 surfaced on GitHub Actions ubuntu-latest.

Root cause

A gdb backtrace captured on the runner showed apps/build_geometry crashing inside std::__format::_Sink<char>::_M_write resolved into libGeoModelWrite.so.6 rather than libstdc++.

The conda geomodel package ships libGeoModelWrite built against an older libstdc++ (GLIBCXX_3.4.31, GCC 12) and emits weak std::__format template instantiations in that library. build_geometry links libGeoModelWrite.so.6 ahead of libstdc++.so.6 in DT_NEEDED order, so the dynamic linker picks the libGeoModelWrite copies of the _Sink / _Scanner internals — whose binary layout does not match what our GCC 14 headers expect. The first std::format call (in CalorimeterFactory::buildStack, line 184 pre-fix) then crashes.

The other tests pass on CI because they aren't linked against libGeoModelWrite (no clash).

Change

Replace std::format with std::to_string + string concatenation in the three Calorimeter source files. The replacements call into well-established libstdc++ symbols that aren't shadowed by libGeoModelWrite.

This can be reverted once libGeoModelWrite is rebuilt against a matching libstdc++.

Test plan

  • `pixi run test` locally with `BUILD_SHARED_LIBS=ON` reproduces the pre-fix crash and passes after the fix
  • CI green on this branch (run 27001131408)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Warning

Review limit reached

@olantwin, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 51 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 78de402f-1cdb-4867-940e-98e0cb8e1e67

📥 Commits

Reviewing files that changed from the base of the PR and between cb46f78 and e451a85.

⛔ Files ignored due to path filters (1)
  • pixi.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .github/workflows/build-test.yml
  • pixi.toml
  • subsystems/Calorimeter/src/CaloBarLayer.cpp
  • subsystems/Calorimeter/src/CaloFibreHPLayer.cpp
  • subsystems/Calorimeter/src/CalorimeterFactory.cpp
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/overlapcheck-segfault

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.

olantwin added 2 commits June 5, 2026 09:06
All dependencies are now available from the prefix.dev/ship channel
(via ship-conda-recipes), so CI no longer needs CVMFS mounts, the
CERN container, or a self-hosted runner. The new workflow runs on
ubuntu-latest with prefix-dev/setup-pixi and a single `pixi run test`
step that configures, builds, and runs ctest.
The OverlapCheck CI test (apps/build_geometry on the GitHub Actions
ubuntu-latest runner) segfaulted on the first std::format call in
CalorimeterFactory::buildStack. A gdb backtrace from CI showed the
crash inside std::__format::_Sink<char>::_M_write — resolved at
runtime into libGeoModelWrite.so.6 rather than libstdc++.so.6.

The conda geomodel package ships libGeoModelWrite built against an
older libstdc++ (GLIBCXX_3.4.31, GCC 12). It emits its own weak
template instantiations for std::__format internals. build_geometry
links libGeoModelWrite ahead of libstdc++ in DT_NEEDED order, so on
the runner the dynamic linker picks the libGeoModelWrite copies of
the format machinery, whose binary layout does not match what our
GCC 14 headers expect — and the first call segfaults.

The CalorimeterBuilds, TimingDetectorBarCount, and BuilderTest
tests pass because they're not linked against libGeoModelWrite, so
the bad symbols never appear in their address space.

Replace std::format with std::to_string + string concatenation in
the Calorimeter sources (CalorimeterFactory, CaloBarLayer,
CaloFibreHPLayer). These call into well-established libstdc++
symbols (operator+, std::to_string) that are not duplicated by
libGeoModelWrite, so they cannot be interposed.

This can be reverted once libGeoModelWrite is rebuilt against a
matching libstdc++.
@olantwin olantwin force-pushed the fix/overlapcheck-segfault branch from 9559425 to ab3487f Compare June 5, 2026 07:14
@olantwin olantwin changed the title fix: OverlapCheck CI segfault (diagnostic in progress) fix(Calorimeter): avoid std::format to work around libstdc++ ABI clash Jun 5, 2026
@olantwin olantwin marked this pull request as ready for review June 5, 2026 07:18
@olantwin olantwin closed this Jun 5, 2026
@olantwin olantwin deleted the fix/overlapcheck-segfault branch June 5, 2026 07:21
olantwin added a commit to ShipSoft/ship-conda-recipes that referenced this pull request Jun 5, 2026
The geomodel artifact currently on prefix.dev was built against an older
libstdc++ (GLIBCXX_3.4.31, GCC 12) and emits weak std::__format template
instantiations from libGeoModelWrite.so.6. Downstream consumers built
with GCC 14 (current conda-forge cxx-compiler) hit those weak symbols
ahead of libstdc++ in DT_NEEDED order, and the layout mismatch crashes
the first std::format call (see ShipSoft/Geometry#27).

Bumping build.number forces rattler-build to produce fresh artifacts
under the current conda-forge pinning, restoring ABI compatibility.
shipgeometry, shipgeometryservice, and aegir are bumped alongside so
the channel ships a consistent set of binaries linked against the
rebuilt geomodel.
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