This issue is a result of a Codex global repository scan.
FIRE::restart() and MSST::restart() store the restart-file status in a C++ bool ok, then broadcast it as one MPI_INT. On receivers, MPI writes an integer-sized payload into a bool-sized object, which can corrupt adjacent stack state and is undefined behavior.
FIRE restart:
|
void FIRE::restart(const std::string& global_readin_dir) |
|
{ |
|
bool ok = true; |
|
|
|
if (!my_rank) |
|
{ |
|
std::stringstream ssc; |
|
ssc << global_readin_dir << "Restart_md.txt"; |
|
std::ifstream file(ssc.str().c_str()); |
|
|
|
if (!file) |
|
{ |
|
ok = false; |
|
} |
|
|
|
if (ok) |
|
{ |
|
file >> step_rst_ >> md_tfirst >> alpha >> negative_count >> dt_max >> md_dt; |
|
file.close(); |
|
} |
|
} |
|
|
|
#ifdef __MPI |
|
MPI_Bcast(&ok, 1, MPI_INT, 0, MPI_COMM_WORLD); |
|
#endif |
MSST restart:
|
void MSST::restart(const std::string& global_readin_dir) |
|
{ |
|
bool ok = true; |
|
|
|
if (!my_rank) |
|
{ |
|
std::stringstream ssc; |
|
ssc << global_readin_dir << "Restart_md.txt"; |
|
std::ifstream file(ssc.str().c_str()); |
|
|
|
if (!file) |
|
{ |
|
ok = false; |
|
} |
|
|
|
if (ok) |
|
{ |
|
file >> step_rst_ >> md_tfirst >> omega[mdp.msst_direction] >> e0 >> v0 >> p0 >> lag_pos; |
|
file.close(); |
|
} |
|
} |
|
|
|
#ifdef __MPI |
|
MPI_Bcast(&ok, 1, MPI_INT, 0, MPI_COMM_WORLD); |
Relevant code:
bool ok = true;
...
MPI_Bcast(&ok, 1, MPI_INT, 0, MPI_COMM_WORLD);
Suggested fix:
Broadcast with MPI_C_BOOL when available, or broadcast an int ok_int and convert explicitly to/from bool. This also makes the code consistent with the actual object size on all ranks.
This issue is a result of a Codex global repository scan.
FIRE::restart()andMSST::restart()store the restart-file status in a C++bool ok, then broadcast it as oneMPI_INT. On receivers, MPI writes an integer-sized payload into a bool-sized object, which can corrupt adjacent stack state and is undefined behavior.FIRE restart:
abacus-develop/source/source_md/fire.cpp
Lines 116 to 140 in 84ca04b
MSST restart:
abacus-develop/source/source_md/msst.cpp
Lines 195 to 218 in 84ca04b
Relevant code:
Suggested fix:
Broadcast with
MPI_C_BOOLwhen available, or broadcast anint ok_intand convert explicitly to/frombool. This also makes the code consistent with the actual object size on all ranks.