Skip to content

Commit

Permalink
Merge pull request #4047 from pnorbert/python-blocks
Browse files Browse the repository at this point in the history
Fix segfault when asking for BlocksInfo for a variable name that does…
  • Loading branch information
pnorbert committed Feb 28, 2024
2 parents adcff33 + 846ba14 commit 02e717e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bindings/Python/py11Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,18 @@ std::vector<std::map<std::string, std::string>> Engine::BlocksInfo(std::string &
const size_t step) const
{
std::vector<std::map<std::string, std::string>> rv;
auto &varMap = m_Engine->m_IO.GetVariables();
auto itVariable = varMap.find(var_name);
if (itVariable == varMap.end())
{
return rv;
}

// Grab the specified variable object and get its type string
adios2::DataType var_type = m_Engine->GetIO().InquireVariableType(var_name);

MinVarInfo *minBlocksInfo = nullptr;
auto itVariable = m_Engine->m_IO.GetVariables().find(var_name);

auto Variable = itVariable->second.get();
minBlocksInfo = m_Engine->MinBlocksInfo(*Variable, 0);
if (minBlocksInfo)
Expand All @@ -293,7 +299,8 @@ std::vector<std::map<std::string, std::string>> Engine::BlocksInfo(std::string &
{
start_ss << ",";
}
start_ss << info.Start[i];
start_ss << (minBlocksInfo->WasLocalValue ? reinterpret_cast<size_t>(info.Start)
: info.Start[i]);
}
}
info_map["Start"] = start_ss.str();
Expand All @@ -310,7 +317,8 @@ std::vector<std::map<std::string, std::string>> Engine::BlocksInfo(std::string &
{
count_ss << ",";
}
count_ss << info.Count[i];
count_ss << (minBlocksInfo->WasLocalValue ? reinterpret_cast<size_t>(info.Count)
: info.Count[i]);
}
}
info_map["Count"] = count_ss.str();
Expand Down

0 comments on commit 02e717e

Please sign in to comment.