diff --git a/include/openPMD/IO/ADIOS/CommonADIOS1IOHandler.hpp b/include/openPMD/IO/ADIOS/CommonADIOS1IOHandler.hpp index 74733781e9..ea89f033d6 100644 --- a/include/openPMD/IO/ADIOS/CommonADIOS1IOHandler.hpp +++ b/include/openPMD/IO/ADIOS/CommonADIOS1IOHandler.hpp @@ -103,7 +103,12 @@ class CommonADIOS1IOHandlerImpl : public AbstractIOHandlerImpl m_openWriteFileHandles; std::unordered_map, ADIOS_FILE *> m_openReadFileHandles; - std::unordered_map > + struct ScheduledRead + { + ADIOS_SELECTION *selection; + std::shared_ptr data; // needed to avoid early freeing + }; + std::unordered_map > m_scheduledReads; std::unordered_map > m_attributeWrites; diff --git a/src/IO/ADIOS/ADIOS1IOHandler.cpp b/src/IO/ADIOS/ADIOS1IOHandler.cpp index 3c38b1adc6..3a6dc803d2 100644 --- a/src/IO/ADIOS/ADIOS1IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS1IOHandler.cpp @@ -296,7 +296,7 @@ std::future ADIOS1IOHandlerImpl::flush() "dataset reading"); for (auto &sel : file.second) - adios_selection_delete(sel); + adios_selection_delete(sel.selection); } m_scheduledReads.clear(); diff --git a/src/IO/ADIOS/CommonADIOS1IOHandler.cpp b/src/IO/ADIOS/CommonADIOS1IOHandler.cpp index 345052ddfc..e50207a74d 100644 --- a/src/IO/ADIOS/CommonADIOS1IOHandler.cpp +++ b/src/IO/ADIOS/CommonADIOS1IOHandler.cpp @@ -728,7 +728,7 @@ void CommonADIOS1IOHandlerImpl::closeFile( "dataset reading"); for (auto &sel : scheduled->second) - adios_selection_delete(sel); + adios_selection_delete(sel.selection); m_scheduledReads.erase(scheduled); } close(handle_read->second); @@ -1183,7 +1183,7 @@ void CommonADIOS1IOHandlerImpl::readDataset( "[ADIOS1] Internal error: Failed to schedule ADIOS read during dataset " "reading"); - m_scheduledReads[f].push_back(sel); + m_scheduledReads[f].push_back({sel, parameters.data}); } template diff --git a/src/IO/ADIOS/ParallelADIOS1IOHandler.cpp b/src/IO/ADIOS/ParallelADIOS1IOHandler.cpp index 20a2d3936e..df6f817098 100644 --- a/src/IO/ADIOS/ParallelADIOS1IOHandler.cpp +++ b/src/IO/ADIOS/ParallelADIOS1IOHandler.cpp @@ -316,7 +316,7 @@ std::future ParallelADIOS1IOHandlerImpl::flush() "dataset reading"); for (auto &sel : file.second) - adios_selection_delete(sel); + adios_selection_delete(sel.selection); } m_scheduledReads.clear();