Skip to content

fix(server): claim the GNU C++ runtime at engine startup - #2720

Merged
stepmikhaylov merged 1 commit into
developfrom
fix/RR-2676-libstdcxx-claim
Oct 20, 2026
Merged

stepmikhaylov merged 1 commit into
developfrom
fix/RR-2676-libstdcxx-claim

Conversation

@stepmikhaylov

@stepmikhaylov stepmikhaylov commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A task that runs parse and then any node importing torch dies at start with
SIGSEGV at 0x20 in libstdc++ — mechanism, dumps and repro in #2676.

The engine now claims the system libstdc++ while the process is still coming up, in
plat::lin::init() beside the Crashpad registration, so the runtime that owns the
locale facet ids is the real one. A JNI library carrying its own statically linked
copy — Tika's prebuilt lib7-Zip-JBinding.so is the one we hit — then loads without
consequence instead of renumbering the facet table under the system runtime's feet.
Every executable picks this up through ap::init().

Linux only; no GNU-unique binding exists on macOS or Windows.

The cost: 0.86 MB resident (file-backed, shared), 0.42 ms at startup, once per
process.
Nothing is interposed and no call path changes.

Re-implements the runtime half of #2677. That PR fixes the same crash by building
the binding from source so no second libstdc++ exists in the process, plus a
Python-side preload in ai/node.py. This does it once, in the engine, and leaves the
binding alone. #2677 keeps everything else it carries — see the comment there.

Type

fix

Testing

WSL Ubuntu 22.04, server:build-core. A/B on one dist with
webhook -> parse -> general_text -> embedding_transformer and one document, this
file the only difference between runs:

engine result
with the claim task alive for the full window, exit=0
reverted RuntimeError: Received terminal system signal
restored exit=0, no fatality

/proc/<task pid>/maps in the surviving runs carries all of it at once: libjvm.so,
lib7-Zip-JBinding.so, libc++.so.1, libstdc++.so.6, libtorch.so,
libtorch_cpu.so, libtorch_cuda.so, libtorch_python.so.

Isolated in a subprocess, the jar's binding followed by a long through
std::ostream is SIGSEGV on both the 16.02-2.01 and 23.01-2.2 prebuilts, and clean
with libstdc++ claimed first.

aptest 99 cases / 40,742,613 assertions and engtest 31 cases pass on the rebuilt
engine. No regression test added yet.

Linked Issue

Fixes #2676 — Linux task dies on start (SIGSEGV at 0x20 in libstdc++) when a pipeline
runs parse followed by General Text or an embedding node.

Not fixed here, and still owned by #2677:

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved Linux startup compatibility by attempting to load a required system library before initialization completes.
    • Startup now continues gracefully with an error log if the library cannot be loaded.

A task running parse beside a node that imports torch died at start with SIGSEGV
at 0x20 in libstdc++: Tika's prebuilt lib7-Zip-JBinding.so carries a statically
linked GCC libstdc++ whose GNU-unique locale facet ids bind process-wide to the
first definer, so loaded into a libc++ engine it renumbered the system runtime's
facet table and the next std::ostream to format a number reached a facet that was
not there.

plat::lin::init() now claims libstdc++.so.6 with RTLD_GLOBAL, beside the Crashpad
registration and for the same reason. One runtime owns the ids and a bundled copy
arriving later is inert. Fails open where the library is absent, since a host
without it cannot load GCC-built code either.

Linux only. Costs 0.86 MB resident, shared and file-backed, and 0.42 ms once per
process.

Fixes #2676

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the module:server C++ engine and server components label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: rocketride-org/rocketride-server/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 044143ed-6a2f-4aa0-9baa-e798459d292f
📥 Commits

Reviewing files that changed from the base of the PR and between 0597125 and 187ec2e.

📒 Files selected for processing: 1
  • packages/server/engine-core/apLib/plat/lin/init.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

Linux initialization now attempts to load libstdc++.so.6 globally with immediate symbol resolution. If the load fails, initialization logs the dynamic-loader error and continues.

Changes: Linux initialization

Layer / File(s) Summary
Preload libstdc++ during initialization
packages/server/engine-core/apLib/plat/lin/init.cpp
init() attempts to load libstdc++.so.6 using RTLD_NOW and RTLD_GLOBAL. A failed load logs dlerror() and does not abort initialization.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: High

Merge Risk: ⚪ Minimal · up to 187ec

No actionable merge-blocking risk is established for this Linux startup change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: claiming the GNU C++ runtime during engine startup on the server.
Linked Issues check Passed The only active directly linked issue is #2676. Its Linux startup requirement is addressed in packages/server/engine-core/apLib/plat/lin/init.cpp: ap::plat::lin::init() calls `dlopen("libstdc++.so…
Out of Scope Changes check Passed The whole-PR diff contains one change in packages/server/engine-core/apLib/plat/lin/init.cpp. It adds the Linux runtime claim that directly supports #2676. It does not add the RAR parser work or the…
Full details: Linked Issues check

Explanation

The only active directly linked issue is #2676. Its Linux startup requirement is addressed in packages/server/engine-core/apLib/plat/lin/init.cpp: ap::plat::lin::init() calls dlopen("libstdc++.so.6", RTLD_NOW | RTLD_GLOBAL) during startup, before later JNI and torch loading. The call fails open and logs the loader error. The change is Linux-specific and targets the reported duplicate-libstdc++ locale-facet crash. The PR reports successful parse-to-text and embedding reproduction runs, plus passing aptest and engtest. Issue #2676 does not require a regression test that is absent here.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff contains one change in packages/server/engine-core/apLib/plat/lin/init.cpp. It adds the Linux runtime claim that directly supports #2676. It does not add the RAR parser work or the 7-Zip-JBinding version change that the PR identifies as #2677 scope. No unrelated source change is present in the reviewable diff.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@stepmikhaylov
stepmikhaylov merged commit 074c316 into develop Oct 20, 2026
@stepmikhaylov
stepmikhaylov deleted the fix/RR-2676-libstdcxx-claim branch October 20, 2026 12:47
asclearuc added a commit that referenced this pull request Oct 20, 2026
…binding

#2720 closes the GNU-unique collision in the engine, so the probes target that:
libstdc++.so.6 is mapped and in the global scope before any Python runs, and the
jar's prebuilt 7-Zip-JBinding then a GCC-built std::ostream user survives in the
engine. A precondition test keeps the jar's binding honest: once upstream stops
exporting a bundled libstdc++, it says the probes can go. No torch and no
compiler needed.

Refs #2676
asclearuc added a commit that referenced this pull request Oct 20, 2026
…op the packages/tika labeler entry

The directory is empty since RarSevenZipParser moved; the labeler glob pointed at nothing.

Refs #2678, #2676, #2720
stepmikhaylov added a commit that referenced this pull request Oct 20, 2026
A task running parse beside a node that imports torch died at start with SIGSEGV
at 0x20 in libstdc++: Tika's prebuilt lib7-Zip-JBinding.so carries a statically
linked GCC libstdc++ whose GNU-unique locale facet ids bind process-wide to the
first definer, so loaded into a libc++ engine it renumbered the system runtime's
facet table and the next std::ostream to format a number reached a facet that was
not there.

plat::lin::init() now claims libstdc++.so.6 with RTLD_GLOBAL, beside the Crashpad
registration and for the same reason. One runtime owns the ids and a bundled copy
arriving later is inert. Fails open where the library is absent, since a host
without it cannot load GCC-built code either.

Linux only. Costs 0.86 MB resident, shared and file-backed, and 0.42 ms once per
process.

Fixes #2676


(cherry picked from commit 074c316)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
stepmikhaylov pushed a commit that referenced this pull request Oct 22, 2026
…binding

#2720 closes the GNU-unique collision in the engine, so the probes target that:
libstdc++.so.6 is mapped and in the global scope before any Python runs, and the
jar's prebuilt 7-Zip-JBinding then a GCC-built std::ostream user survives in the
engine. A precondition test keeps the jar's binding honest: once upstream stops
exporting a bundled libstdc++, it says the probes can go. No torch and no
compiler needed.

Refs #2676
stepmikhaylov pushed a commit that referenced this pull request Oct 22, 2026
…op the packages/tika labeler entry

The directory is empty since RarSevenZipParser moved; the labeler glob pointed at nothing.

Refs #2678, #2676, #2720
asclearuc added a commit that referenced this pull request Oct 22, 2026
…libstdc++ claim (#2677)

* fix(parse): bring RarSevenZipParser along from packages/tika; RAR extracted nothing since #2440

#2440 moved the Tika code from packages/tika into the parse node's Java library but
left parsers/rar/RarSevenZipParser.java behind, in a module nothing builds any more.
ConfigBuilder still removed Tika's junrar RarParser and added that class by name, so
with the binding loaded RAR had no parser at all: Tika mapped application/x-rar-compressed
to nothing and every RAR4/RAR5 archive came out empty, silently, on every platform.
The class moves to the node library; the Java-side probe now maps RAR to
RarSevenZipParser and a RAR5 archive yields its member text.

Refs #2676

* test(parse): RAR5 archive end to end through 7-Zip-JBinding

webhook -> parse -> response_text with a one-file RAR5 archive built in the test
(stored, no compression, standard library only); the member's text must be in the
response. Exercises SevenZip.initSevenZipFromPlatformJAR() and RarSevenZipParser, which
the ctypes probes and a text/plain pipeline cannot: TikaApi.init() swallows a load
failure and parse carries on with RAR5 off. Objects need objinfo["size"]: parse skips
a size-0 object as empty, so the pipeline test sets it too. CodeRabbit on #2677.

Refs #2678

* fix(parse): swap in RarSevenZipParser only when the class resolves

ConfigBuilder trusted the class name: when #2440 left RarSevenZipParser out of the
jar, the swap removed Tika's RarParser and installed nothing, and RAR extracted
nothing without a word. Check Class.forName as well as isSevenZipReady(), log which
one is missing, and keep junrar otherwise. JUnit pins that the class is in the jar.

Refs #2678

* test(parse): probe the engine's libstdc++ claim instead of a rebuilt binding

#2720 closes the GNU-unique collision in the engine, so the probes target that:
libstdc++.so.6 is mapped and in the global scope before any Python runs, and the
jar's prebuilt 7-Zip-JBinding then a GCC-built std::ostream user survives in the
engine. A precondition test keeps the jar's binding honest: once upstream stops
exporting a bundled libstdc++, it says the probes can go. No torch and no
compiler needed.

Refs #2676

* chore: changelog and NOTICE for the RAR fix and the runtime claim; drop the packages/tika labeler entry

The directory is empty since RarSevenZipParser moved; the labeler glob pointed at nothing.

Refs #2678, #2676, #2720

* test(parse): skip the RAR5 end-to-end test on Apple Silicon

sevenzipjbinding-all-platforms 16.02-2.01 ships a Mac-x86_64 binding only; on an
arm64 JVM it does not load, TikaApi.init() turns RAR5 off and ConfigBuilder keeps
junrar, so the test cannot pass there until the bump to 23.01-2.2 (#2734), whose
Mac dylib is universal.

Refs #2678, #2734

* build(docker): run the image's ldd check over the Linux natives inside the jars too

The JVM loads them in a task, and a jar bump can bring a build that needs a
library the image lacks. Extract the x86-64 glibc .so entries of java/lib/*.jar
with the engine's Python, run the same ldd sweep, drop them. ldd proves that
dependencies resolve, not that symbols do not collide (#2676 had clean
dependencies); that stays a separate check.

Refs #2677
mithileshgau pushed a commit that referenced this pull request Oct 23, 2026
Brings in the Linux 7-Zip native library fix (#2720) that the Ubuntu
node tests need.

Refs #2730
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
…org#2720)

A task running parse beside a node that imports torch died at start with SIGSEGV
at 0x20 in libstdc++: Tika's prebuilt lib7-Zip-JBinding.so carries a statically
linked GCC libstdc++ whose GNU-unique locale facet ids bind process-wide to the
first definer, so loaded into a libc++ engine it renumbered the system runtime's
facet table and the next std::ostream to format a number reached a facet that was
not there.

plat::lin::init() now claims libstdc++.so.6 with RTLD_GLOBAL, beside the Crashpad
registration and for the same reason. One runtime owns the ids and a bundled copy
arriving later is inert. Fails open where the library is absent, since a host
without it cannot load GCC-built code either.

Linux only. Costs 0.86 MB resident, shared and file-backed, and 0.42 ms once per
process.

Fixes rocketride-org#2676

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
… the engine's libstdc++ claim (rocketride-org#2677)

* fix(parse): bring RarSevenZipParser along from packages/tika; RAR extracted nothing since rocketride-org#2440

rocketride-org#2440 moved the Tika code from packages/tika into the parse node's Java library but
left parsers/rar/RarSevenZipParser.java behind, in a module nothing builds any more.
ConfigBuilder still removed Tika's junrar RarParser and added that class by name, so
with the binding loaded RAR had no parser at all: Tika mapped application/x-rar-compressed
to nothing and every RAR4/RAR5 archive came out empty, silently, on every platform.
The class moves to the node library; the Java-side probe now maps RAR to
RarSevenZipParser and a RAR5 archive yields its member text.

Refs rocketride-org#2676

* test(parse): RAR5 archive end to end through 7-Zip-JBinding

webhook -> parse -> response_text with a one-file RAR5 archive built in the test
(stored, no compression, standard library only); the member's text must be in the
response. Exercises SevenZip.initSevenZipFromPlatformJAR() and RarSevenZipParser, which
the ctypes probes and a text/plain pipeline cannot: TikaApi.init() swallows a load
failure and parse carries on with RAR5 off. Objects need objinfo["size"]: parse skips
a size-0 object as empty, so the pipeline test sets it too. CodeRabbit on rocketride-org#2677.

Refs rocketride-org#2678

* fix(parse): swap in RarSevenZipParser only when the class resolves

ConfigBuilder trusted the class name: when rocketride-org#2440 left RarSevenZipParser out of the
jar, the swap removed Tika's RarParser and installed nothing, and RAR extracted
nothing without a word. Check Class.forName as well as isSevenZipReady(), log which
one is missing, and keep junrar otherwise. JUnit pins that the class is in the jar.

Refs rocketride-org#2678

* test(parse): probe the engine's libstdc++ claim instead of a rebuilt binding

rocketride-org#2720 closes the GNU-unique collision in the engine, so the probes target that:
libstdc++.so.6 is mapped and in the global scope before any Python runs, and the
jar's prebuilt 7-Zip-JBinding then a GCC-built std::ostream user survives in the
engine. A precondition test keeps the jar's binding honest: once upstream stops
exporting a bundled libstdc++, it says the probes can go. No torch and no
compiler needed.

Refs rocketride-org#2676

* chore: changelog and NOTICE for the RAR fix and the runtime claim; drop the packages/tika labeler entry

The directory is empty since RarSevenZipParser moved; the labeler glob pointed at nothing.

Refs rocketride-org#2678, rocketride-org#2676, rocketride-org#2720

* test(parse): skip the RAR5 end-to-end test on Apple Silicon

sevenzipjbinding-all-platforms 16.02-2.01 ships a Mac-x86_64 binding only; on an
arm64 JVM it does not load, TikaApi.init() turns RAR5 off and ConfigBuilder keeps
junrar, so the test cannot pass there until the bump to 23.01-2.2 (rocketride-org#2734), whose
Mac dylib is universal.

Refs rocketride-org#2678, rocketride-org#2734

* build(docker): run the image's ldd check over the Linux natives inside the jars too

The JVM loads them in a task, and a jar bump can bring a build that needs a
library the image lacks. Extract the x86-64 glibc .so entries of java/lib/*.jar
with the engine's Python, run the same ldd sweep, drop them. ldd proves that
dependencies resolve, not that symbols do not collide (rocketride-org#2676 had clean
dependencies); that stays a separate check.

Refs rocketride-org#2677
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:server C++ engine and server components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux task dies on start (SIGSEGV at 0x20 in libstdc++) when a pipeline runs parse followed by General Text or an embedding node

3 participants