Skip to content

Commit 4d3be55

Browse files
committed
Fix bug in ADIOS2 that leaks dataset configs into other datasets
1 parent 7e01d94 commit 4d3be55

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ void ADIOS2IOHandlerImpl::createDataset(
775775
filePos->gd = GroupOrDataset::DATASET;
776776
auto const varName = nameOfVariable(writable);
777777

778-
json::TracingJSON config = [&]() {
778+
json::TracingJSON config = [&]() -> json::ParsedConfig {
779779
if (!m_buffered_dataset_config.has_value())
780780
{
781781
// we are only interested in these values from the global config
@@ -791,17 +791,20 @@ void ADIOS2IOHandlerImpl::createDataset(
791791
*m_buffered_dataset_config,
792792
nlohmann::json::parse(mask_for_global_conf));
793793
}
794+
auto const &buffered_config = *m_buffered_dataset_config;
794795
auto parsed_config = json::parseOptions(
795796
parameters.options, /* considerFiles = */ false);
796797
if (auto adios2_config_it = parsed_config.config.find("adios2");
797798
adios2_config_it != parsed_config.config.end())
798799
{
799-
adios2_config_it.value() = json::merge(
800-
*m_buffered_dataset_config, adios2_config_it.value());
800+
auto copy = buffered_config;
801+
json::merge(copy, adios2_config_it.value());
802+
copy = nlohmann::json{{"adios2", std::move(copy)}};
803+
parsed_config.config = std::move(copy);
801804
}
802805
else
803806
{
804-
parsed_config.config["adios2"] = *m_buffered_dataset_config;
807+
parsed_config.config["adios2"] = buffered_config;
805808
}
806809
return parsed_config;
807810
}();
@@ -897,7 +900,11 @@ void ADIOS2IOHandlerImpl::createDataset(
897900
throw error::OperationUnsupportedInBackend(
898901
"ADIOS2",
899902
"Shape for local value array must be a 1D array "
900-
"equivalent to the MPI size.");
903+
"equivalent to the MPI size ('" +
904+
varName + "' has shape " +
905+
auxiliary::format_vec(parameters.extent) +
906+
", but should have shape [" +
907+
std::to_string(required_size) + "]).");
901908
}
902909
return adios2::Dims{adios2::LocalValueDim};
903910
}

0 commit comments

Comments
 (0)