Commit e44904d1 authored by Chris Cantwell's avatar Chris Cantwell

Added checks for to avoid dereferencing null communicators.

parent d1bca648
......@@ -82,7 +82,11 @@ CommMpi::CommMpi(int narg, char *arg[]) : Comm(narg, arg)
m_isLogging = false;
m_isRecovering = false;
m_nSpares = opts["spares"].as<int>();
m_nSpares = 0;
if (opts.count("spares"))
{
m_nSpares = opts["spares"].as<int>();
}
int init = 0;
MPI_Initialized(&init);
......@@ -975,26 +979,40 @@ cout << "Colour is " << colour << endl;
cout << "Restored a comm" << endl;
}
m_derivedComm.push_back(cmpi);
cout << "New comm is of size: " << cmpi->GetSize() << endl;
cout << "Restoring its state..." << endl << endl;
cout << "### Restore sub-communicator ###" << endl;
cmpi->RestoreState();
if (cmpi)
{
cout << "New comm is of size: " << cmpi->GetSize() << endl;
cout << "Restoring its state..." << endl << endl;
cout << "### Restore sub-communicator ###" << endl;
cmpi->RestoreState();
}
else
{
cout << "New comm is null." << endl;
}
cout << "### Finished restore of sub-communicator ###" << endl << endl;
}
else // surviving node
{
CommMpiSharedPtr cmpi = (*derivedCommIt);
cout << "Previously comm is of size: " << cmpi->GetSize() << endl;
cmpi->ReplaceComm(tmpComm);
cout << "Replaced comm is of size: " <<
cmpi->GetSize() << endl;
int size;
MPI_Comm_size(cmpi->m_comm, &size);
cout << "Underlying comm is of size: " << size << endl;
cout << "Restoring its state..." << endl << endl;
cout << "### Restore sub-communicator ###" << endl;
cmpi->RestoreState();
cout << "### Finished restore of sub-communicator ###" << endl << endl;
if (cmpi)
{
cout << "Previously comm is of size: " << cmpi->GetSize() << endl;
cmpi->ReplaceComm(tmpComm);
cout << "Replaced comm is of size: " <<
cmpi->GetSize() << endl;
int size;
MPI_Comm_size(cmpi->m_comm, &size);
cout << "Underlying comm is of size: " << size << endl;
cout << "Restoring its state..." << endl << endl;
cout << "### Restore sub-communicator ###" << endl;
cmpi->RestoreState();
cout << "### Finished restore of sub-communicator ###" << endl << endl;
}
else
{
cout << "Derived comm was null." << endl;
}
derivedCommIt++;
}
}
......@@ -1072,7 +1090,10 @@ void CommMpi::v_BeginTransactionLog()
if (m_isRecovering) {
for (auto x : m_derivedComm)
{
x->m_isRecovering = true;
if (x)
{
x->m_isRecovering = true;
}
}
}
}
......@@ -1086,7 +1107,14 @@ void CommMpi::v_EndTransactionLog()
for (auto x : m_derivedComm)
{
std::cout << "Ending transaction log on derived comm." << std::endl;
x->EndTransactionLog();
if (x)
{
x->EndTransactionLog();
}
else
{
std::cout << " -> Comm was null." << std::endl;
}
}
if (m_isRecovering)
......
......@@ -265,7 +265,7 @@ namespace Nektar
{
try {
double r = (double)rand()/RAND_MAX;
if (r < 0.001 && failureOccured < failureMax) {
if (r < 0.01 && failureOccured < failureMax) {
cout << "COMMITTING SUICIDE!" << endl;
int blah;
cin >> blah;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment