Fix double free problem when working with interactive belief explorer #185
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running our CAV'23 algorithm SAYNT in PAYNT, which uses Storm's POMDP model checker we have been getting a double free error at the end. From my debugging, I found the issue is caused by exposing a shared_ptr object via the bound function "BeliefExplorationPomdpModelChecker::getInteractiveBeliefExplorer". In the current implementation, we need this object to update the cut-off values used in belief MDP model checking.
Even though the documentation of pybind11 says that "pybind11 supports std::unique_ptr and std::shared_ptr right out of the box", this has been reported to be untrue: pybind/pybind11#5058. The issue seems to be acknowledged by the authors as in the pybind11 repository there's a branch called smart_holder (more info here) which is being kept up-to-date with the master branch but contains a reworked implementation for smart pointers. One possible solution to this problem would be to use this branch, but I haven't tried that, so I can't confirm whether this helps.
This fix avoids accessing the BeliefMdpExplorer object from the function mentioned above by creating a bind to a newly created function "BeliefExplorationPomdpModelChecker::setFMSchedValueList" (see moves-rwth/storm#623) that will then proceed to call "storm::builder::BeliefMdpExplorer<Pomdp, ValueType>::setFMSchedValueList" inside Storm to achieve the same functionality.
If we agree this is a good fix, I will also remove the binding for the BeliefMdpExplorer class and the function "BeliefExplorationPomdpModelChecker::getInteractiveBeliefExplorer" as these are the culprits for the double free issue.
Depends on moves-rwth/storm#623
@AlexBork do you agree with this solution (please look at the PR in Storm as well)?