Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PodioOutput seg faults when MarlinProcessorWrapper runs out of events #94

Closed
tmadlener opened this issue Nov 22, 2022 · 1 comment · Fixed by key4hep/k4FWCore#159
Closed
Labels
bug Something isn't working

Comments

@tmadlener
Copy link
Contributor

tmadlener commented Nov 22, 2022

Disclaimer: It is entirely possible that this is in fact an issue of k4FWCore, but I observed it first when using k4MarlinWrapper and the converters, so opening here first.

In short PodioOutput seg faults when trying to fill its internal data tree, when a wrapped Marlin processor has no LCEvent. This seems a bit reminiscent of #36.

A minimal reproducer looks like this. The input file for this is the muons.slcio that is downloaded to test/inputFiles/

from Gaudi.Configuration import *

from Configurables import (
    LcioEvent,
    MarlinProcessorWrapper,
    PodioOutput,
    Lcio2EDM4hepTool,
    k4DataSvc,
)

algList = []

evtSvc = k4DataSvc("EventDataSvc")

read = LcioEvent()
read.Files = ["muons.slcio"]

edmConvTool = Lcio2EDM4hepTool("LCIO2EDM4hep")
edmConvTool.convertAll = True

monitor = MarlinProcessorWrapper("monitor")
monitor.ProcessorType = "Statusmonitor"
monitor.Lcio2EDM4hepTool = edmConvTool

output = PodioOutput("EDM4hepOutput", filename="output.edm4hep.root")
output.outputCommands = ["keep *"]

algList.append(read)
algList.append(monitor)
algList.append(output)

from Configurables import ApplicationMgr

ApplicationMgr(
    TopAlg=algList, 
    EvtSel="NONE", 
    EvtMax=11,  # THIS IS THE PROBLEM, muons.slcio has only 10 events
    ExtSvc=[evtSvc], 
    OutputLevel=WARNING
)

running this via k4run makes the whole thing seg-fault in PodioOutput. There are some warnings before that, that at least hint at the fact, that the event loop is terminated one event too late, i.e. it looks like the event in which LcioEvent detects, that it has no events left, is still run. All the MarlinProcessorWrappers handle that gracefully, but for some reason the PodioOutput seems to run into some invalid memory access. From the stacktrace, the culprit is:
https://github.com/key4hep/k4FWCore/blob/e4b846e4e25fa3967fdbb1cf4ec02de8ad8bca8a/k4FWCore/components/PodioOutput.cpp#L137

As a side note: removing the output algorithm from the algorithms to run, results in a graceful termination, but even then, there is a warning about a nullptr LCIO event:

[...]
Saving status: 1
Saving status: 1
monitor           WARNING LCIO Event reading returned nullptr, so MarlinProcessorWrapper won't execute
EventLoopMgr      SUCCESS Terminating event processing loop due to scheduled stop
[ MESSAGE "monitor"] Statusmonitor::end()  monitor processed 10 events in 0 runs 

The output when segfaulting is the same, up to the line where the EventLoopMgr gracefully terminates.

@tmadlener tmadlener added the bug Something isn't working label Nov 22, 2022
@tmadlener
Copy link
Contributor Author

Potentially related to key4hep/k4FWCore#125

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant