fix(construction): removed std::optional arguments for weakRateInterpolator
Passing weak rate interpolator as an std::optional was resulting in use-after-free bugs due to std::optional making a copy of WeakRateInterpolator. This resulted in segfaults. Since we have the new construction semantics with flags this is no longer needed so the optional argument has been removed in favor of a simple const &
This commit is contained in:
@@ -105,7 +105,7 @@ namespace gridfire {
|
||||
*/
|
||||
reaction::ReactionSet build_nuclear_network(
|
||||
const fourdst::composition::Composition &composition,
|
||||
const std::optional<rates::weak::WeakRateInterpolator> &weakInterpolator,
|
||||
const rates::weak::WeakRateInterpolator &weakInterpolator,
|
||||
BuildDepthType maxLayers = NetworkBuildDepth::Full,
|
||||
NetworkConstructionFlags ReactionTypes = NetworkConstructionFlags::DEFAULT
|
||||
);
|
||||
|
||||
@@ -40,16 +40,15 @@ namespace {
|
||||
|
||||
|
||||
gridfire::reaction::ReactionSet register_weak_reactions(
|
||||
const std::optional<gridfire::rates::weak::WeakRateInterpolator> &weakInterpolator,
|
||||
const gridfire::rates::weak::WeakRateInterpolator &weakInterpolator,
|
||||
const gridfire::NetworkConstructionFlags reactionTypes
|
||||
) {
|
||||
gridfire::reaction::ReactionSet weak_reaction_pool;
|
||||
assert(weakInterpolator.has_value());
|
||||
if (!has_flag(reactionTypes, gridfire::NetworkConstructionFlags::WEAK)) {
|
||||
return weak_reaction_pool;
|
||||
}
|
||||
|
||||
for (const auto& parent_species: weakInterpolator->available_isotopes()) {
|
||||
for (const auto& parent_species: weakInterpolator.available_isotopes()) {
|
||||
std::expected<fourdst::atomic::Species, fourdst::atomic::SpeciesErrorType> upProduct = fourdst::atomic::az_to_species(
|
||||
parent_species.a(),
|
||||
parent_species.z() + 1
|
||||
@@ -64,7 +63,7 @@ namespace {
|
||||
std::make_unique<gridfire::rates::weak::WeakReaction>(
|
||||
parent_species,
|
||||
gridfire::rates::weak::WeakReactionType::BETA_PLUS_DECAY,
|
||||
*weakInterpolator
|
||||
weakInterpolator
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -73,7 +72,7 @@ namespace {
|
||||
std::make_unique<gridfire::rates::weak::WeakReaction>(
|
||||
parent_species,
|
||||
gridfire::rates::weak::WeakReactionType::ELECTRON_CAPTURE,
|
||||
*weakInterpolator
|
||||
weakInterpolator
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -84,7 +83,7 @@ namespace {
|
||||
std::make_unique<gridfire::rates::weak::WeakReaction>(
|
||||
parent_species,
|
||||
gridfire::rates::weak::WeakReactionType::BETA_MINUS_DECAY,
|
||||
*weakInterpolator
|
||||
weakInterpolator
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -93,7 +92,7 @@ namespace {
|
||||
std::make_unique<gridfire::rates::weak::WeakReaction>(
|
||||
parent_species,
|
||||
gridfire::rates::weak::WeakReactionType::POSITRON_CAPTURE,
|
||||
*weakInterpolator
|
||||
weakInterpolator
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -127,7 +126,7 @@ namespace gridfire {
|
||||
|
||||
ReactionSet build_nuclear_network(
|
||||
const Composition& composition,
|
||||
const std::optional<rates::weak::WeakRateInterpolator> &weakInterpolator,
|
||||
const rates::weak::WeakRateInterpolator &weakInterpolator,
|
||||
BuildDepthType maxLayers,
|
||||
NetworkConstructionFlags ReactionTypes
|
||||
) {
|
||||
|
||||
@@ -55,9 +55,10 @@ namespace gridfire {
|
||||
}
|
||||
}
|
||||
if (primeReactions.empty()) {
|
||||
LOG_ERROR(m_logger, "No priming reactions found for species '{}'.", primingSpecies.name());
|
||||
m_logger->flush_log();
|
||||
throw std::runtime_error("No priming reactions found for species '" + std::string(primingSpecies.name()) + "'.");
|
||||
LOG_INFO(m_logger, "No priming reactions found for species '{}', returning empty peName set.", primingSpecies.name());
|
||||
return std::vector<std::string>{};
|
||||
// m_logger->flush_log();
|
||||
// throw std::runtime_error("No priming reactions found for species '" + std::string(primingSpecies.name()) + "'.");
|
||||
}
|
||||
std::vector<std::string> primingReactionSet(primeReactions.begin(), primeReactions.end());
|
||||
// LOG_INFO(m_logger, "Constructed priming reaction set with {} reactions for species '{}'.", primingReactionSet.size(), primingSpecies.name());
|
||||
|
||||
Reference in New Issue
Block a user