Repository navigation
jazzy, lyrical, rolling: fix class_loader exit abort (console_bridge static order) - #243
Conversation
…l exit On exit, class_loader's static ClassLoaderPtrVectorImpl destroys the still-held ClassLoaders, and ~ClassLoader() logs through console_bridge, whose output handler (a function-local static) can already be gone: "mutex lock failed", std::terminate, exit 134 (e.g. `rqt --list-plugins` on macOS). ClassLoaderDependency() already orders class_loader's own statics before class_loader_ptrs_; console_bridge::getLogLevel() there does the same for console_bridge's. Same change as ros/class_loader#252. humble's class_loader 2.2.0 has no ClassLoaderDependency and doesn't abort. lyrical/rolling: the previous patch only made getAvailableClassesForLibrary's loader const, which upstream already has in 2.9.4/3.0.2 (on rolling it applied with an offset to another occurrence); it is replaced by this fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ABI check (linux-64)jazzy linux-64: 2 can be bumped on their own2 packages can be bumped on their own (compatible: 2)
Compared with the newest builds on https://conda.anaconda.org/robostack-jazzy/linux-64. lyrical linux-64: **1 need their dependents rebuilt**, 6 can be bumped on their own
6 packages can be bumped on their own (compatible: 6)
Compared with the newest builds on https://repo.prefix.dev/robostack-lyrical/linux-64. rolling linux-64: **1 need their dependents rebuilt**, 1 to review (changed headers), 5 can be bumped on their own
5 packages can be bumped on their own (compatible: 5)
Compared with the newest builds on https://repo.prefix.dev/robostack-rolling/linux-64. About this checkEach package this pull request built, compared with its newest released build (
Exported symbols are compared (the released packages are stripped, so struct layouts aren't); unchanged installed headers rule out layout and inline changes, changed ones are listed for review. Dependents to rebuild are the released ones linking to a changed library. A changed pin is part of the comparison. |
traversaro
left a comment
There was a problem hiding this comment.
Good to go for me, but those are the classical issues that it is quite easy to regress on. If the agent could find a test that captures this problem so we make sure we do not regress, it would be great.
…the loader mutex alive
- shared/tests/ros2-class-loader.yaml: builds a small plugin and a program that loads it
through a MultiLibraryClassLoader it never destroys, and checks that the program exits 0.
Without the fix it aborts on macOS ("mutex lock failed", exit 134) with the published
lyrical/rolling class_loader; it passes with this PR's builds on jazzy, lyrical and rolling
(and with humble's 2.2.0).
- rolling (class_loader 3.0.2): the test also caught that 3.0's getLoaderMutex() (a static
added for concurrent load/unload) isn't in ClassLoaderDependency either, so
~ClassLoader()'s unload at exit locked a destroyed recursive_mutex. It is now declared in
class_loader_core.hpp and constructed in ClassLoaderDependency() as well.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@traversaro, good call: the test found a second instance of the same bug. I added Results on osx-arm64:
On Linux it runs as a smoke test only: locking a destroyed mutex doesn't throw there. On rolling, the test caught a second instance. class_loader 3.0 added another static, I haven't added that second fix to ros/class_loader#252 yet; it affects upstream rolling the same way. 🤖 Claude (AI assistant), on behalf of @Tobias-Fischer |
|
Great, thanks! |
On macOS, processes that still hold
ClassLoaders at exit abort, for examplerqt --list-pluginsand closing rqt:mutex lock failed, thenstd::terminateand exit code 134.Cause: class_loader's static
ClassLoaderPtrVectorImpldestroys the remaining loaders at exit.~ClassLoader()logs through console_bridge, whose output handler (a function-local static) has already been destroyed by then.ClassLoaderDependency()already makes sure class_loader's own statics outliveclass_loader_ptrs_. Callingconsole_bridge::getLogLevel()there does the same for console_bridge's.Fix: the same one-line change as ros/class_loader#252, as
patch/ros2-class-loader.patchwith build-number bumps:ClassLoaderDependencyand doesn't abort, so it's unchanged.ros2-class-loader.patchonly madegetAvailableClassesForLibrary'sloaderconst. Upstream already has that in 2.9.4 and 3.0.2; on rolling, the old hunk applied with an offset to a different line. It's replaced by this fix.rolling only (class_loader 3.0): 3.0 added another static,
getLoaderMutex(), which serializes load and unload. It also wasn't inClassLoaderDependency, so with only the console_bridge fix,~ClassLoader()still aborted at exit, this time locking a destroyedrecursive_mutex. The rolling patch movesgetLoaderMutex()out of the anonymous namespace, declares it inclass_loader_core.hpp, and calls it inClassLoaderDependency()too.Regression test:
shared/tests/ros2-class-loader.yaml(unix) builds a small plugin and a program that loads it through aMultiLibraryClassLoaderit never destroys, then checks that the program exits 0. On macOS it aborts with the published lyrical and rolling class_loader (exit 134) and passes with this PR's builds on jazzy, lyrical and rolling; humble's class_loader 2.2.0 passes too. On Linux it runs as a smoke test: locking a destroyed mutex doesn't throw there.Tested on osx-arm64: built all three.
rqt --list-plugins, run offscreen, exits with 134 using the published class_loader and 0 with the patched one, on lyrical and rolling. Jazzy was checked the same way earlier.🤖 Generated with Claude Code