Our simulator crashed after the main termination,
which was caused by the Simgrid energy plugin
calling host_energy->update() whereas host_energy
was null.
This commit simply adds a test about host_energy
being null or not before using it in function
onHostDestruction of src/surf/plugins/energy.cpp.
if (dynamic_cast<simgrid::surf::VirtualMachine*>(surf_host))
return;
HostEnergy *host_energy = host.extension<HostEnergy>();
if (dynamic_cast<simgrid::surf::VirtualMachine*>(surf_host))
return;
HostEnergy *host_energy = host.extension<HostEnergy>();
- host_energy->update();
- XBT_INFO("Total energy of host %s: %f Joules",
- host.name().c_str(), host_energy->getConsumedEnergy());
+ if (host_energy != nullptr)
+ {
+ host_energy->update();
+ XBT_INFO("Total energy of host %s: %f Joules",
+ host.name().c_str(), host_energy->getConsumedEnergy());
+ }
}
/* **************************** Public interface *************************** */
}
/* **************************** Public interface *************************** */