Skip to content

Commit 5c17a02

Browse files
committed
Fix bug in ADIOS2 that leaks dataset configs into other datasets
1 parent 0cdbc85 commit 5c17a02

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
@@ -774,7 +774,7 @@ void ADIOS2IOHandlerImpl::createDataset(
774774
filePos->gd = GroupOrDataset::DATASET;
775775
auto const varName = nameOfVariable(writable);
776776

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

0 commit comments

Comments
 (0)