Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use after free in Constrint and Variable #152

Closed
Andful opened this issue Sep 17, 2024 · 5 comments
Closed

Use after free in Constrint and Variable #152

Andful opened this issue Sep 17, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Andful
Copy link

Andful commented Sep 17, 2024

When inspecting Model and Constraint, I noticed that Model::drop frees every constraint, variable, but Constrain::name and Variable::name assume them not to be freed.

use russcip::prelude::*;

fn main() {
    // Create model
    let mut model = Model::new()
        .hide_output()
        .include_default_plugins()
        .create_prob("test")
        .set_obj_sense(ObjSense::Maximize);

    // Add variables
    let x1 = model.add_var(0., f64::INFINITY, 3., "x1", VarType::Integer);
    
    drop(model);

    println!("{}", x1.name());
}

This causes segmentation fault

@mmghannam
Copy link
Member

Yes that's definitely a problem, but we should wait till #151 is resolved.

@mmghannam mmghannam added the bug Something isn't working label Oct 10, 2024
@mmghannam
Copy link
Member

The constraint case should be solved in #158

@Andful
Copy link
Author

Andful commented Oct 21, 2024

I think the same holds for Variables, no?

@mmghannam
Copy link
Member

I think the same holds for Variables, no?

Yes yes, that's what I'll work on next. Will close issue this only after.

@mmghannam
Copy link
Member

I think we're fully memory safe now :) Thanks again @Andful and feel free to reopen if you find any more issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants