Skip to content

Commit 8139897

Browse files
committed
testing Pre-load streamer plugins before Geant4 creates worker threads
1 parent 9b9c2cf commit 8139897

6 files changed

Lines changed: 31 additions & 6 deletions

File tree

.github/workflows/dockers_deploy_and_test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ jobs:
220220
221221
- name: Download logs artifacts (all arches)
222222
if: ${{ always() }}
223-
uses: actions/download-artifact@v4
223+
uses: actions/download-artifact@v7
224224
with:
225225
pattern: logs-${{ env.TAG4 }}-*
226226
path: ${{ runner.temp }}/downloaded-logs
@@ -248,5 +248,3 @@ jobs:
248248
name: summary-${{ env.TAG4 }}-manifest
249249
path: ${{ env.MANIFEST_SUMMARY_FILE }}
250250
if-no-files-found: warn
251-
252-

.github/workflows/update-binder.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout binder-tutorials repo
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v6
1616
with:
1717
repository: gemc/binder-tutorials
1818
token: ${{ secrets.BINDER_REPO_PAT }} # PAT with repo write access

gemc.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "gui.h"
1616
#include "gdetectorConstruction.h"
1717
#include "gaction.h"
18+
#include "gstreamer.h"
1819

1920
int main(int argc, char* argv[]) {
2021

@@ -36,6 +37,11 @@ int main(int argc, char* argv[]) {
3637
// random engine set by options
3738
gemc::start_random_engine(gopts, log);
3839

40+
// Pre-load streamer plugins before Geant4 creates worker threads. Sanitized Linux
41+
// builds can fail late dlopen() calls from workers with static TLS exhaustion.
42+
auto preloaded_gstreamer_map = gstreamer::preloadGStreamerPlugins(gopts);
43+
(void) preloaded_gstreamer_map;
44+
3945
// init geant4 run manager with then number of threads coming from options. always fails if unavailable
4046
auto runManager = std::unique_ptr<G4RunManager>(G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default, true, nthreads));
4147

gstreamer/examples/gstreamer_example.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ int main(int argc, char* argv[]) {
166166
"for run number 1 with variation 'default'.");
167167
}
168168

169+
// Load streamer plugins before worker threads start. Sanitized Linux builds can fail
170+
// late dlopen() calls from workers with static TLS exhaustion.
171+
auto preloaded_gstreamer_map = gstreamer::preloadGStreamerPlugins(gopts);
172+
(void) preloaded_gstreamer_map;
173+
169174
run_simulation_in_threads(nevents, nthreads, log, dynamicRoutinesMap, gopts);
170175

171176
return EXIT_SUCCESS;
172-
}
177+
}

gstreamer/gstreamer.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,4 +602,19 @@ namespace gstreamer {
602602
return gstreamers;
603603
}
604604

605-
} // namespace gstreamer
605+
/**
606+
* \ingroup gstreamer_core_api
607+
* \brief Preload configured streamer plugins before worker threads are started.
608+
*
609+
* Linux sanitizer builds can fail when a plugin with static TLS is first loaded from
610+
* a worker thread. Keeping this map alive preserves the dlopen handles while later
611+
* per-thread streamer instances are created.
612+
*
613+
* \param gopts Parsed options container supplying streamer definitions.
614+
* \return Shared pointer that should be retained until threaded streaming is complete.
615+
*/
616+
inline std::shared_ptr<const gstreamersMap> preloadGStreamerPlugins(const std::shared_ptr<GOptions>& gopts) {
617+
return gstreamersMapPtr(gopts);
618+
}
619+
620+
} // namespace gstreamer

releases/0.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@ Both x86_64 and ARM64 platforms are supported.
8080
- Cleaned up Meson test behavior by fixing duplicate test names and making
8181
ROOT-dependent tests conditional on ROOT availability
8282
- Using $SIM_HOME instead of $GEMC for installation paths
83+
- Pre-load streamer plugins before Geant4 creates worker threads
8384
- Various code cleanups

0 commit comments

Comments
 (0)