scipopt / russcip

Rust interface for SCIP
https://crates.io/crates/russcip
Apache License 2.0
37 stars 11 forks source link

Add lifetime to solution #149

Closed Andful closed 3 weeks ago

Andful commented 1 month ago

This is my proposed solution to #138. Had to change create_sol to admit &self instead of &mut self (because otherwise model cannot be borrowed). With this changes should make it not possible to perform use after free (with solution, clone_for_plugin seems to also allow use after free). The tests pass otherwise.

Do of this what you want.

Andful commented 1 month ago

A more robust solution might be to add a lifetime directly to ScipPtr. So have OwnedScip and ScipRef<'a> instead of the consumed field.

mmghannam commented 3 weeks ago

Thank you very much @Andful! This solution works great for now and I added your suggestion as an issue to tackle later.

Fixes #138