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

Creating a tactic from an invalid tactic results in a SIGSEGV #338

Open
bakerk98 opened this issue Mar 21, 2025 · 1 comment
Open

Creating a tactic from an invalid tactic results in a SIGSEGV #338

bakerk98 opened this issue Mar 21, 2025 · 1 comment

Comments

@bakerk98
Copy link

bakerk98 commented Mar 21, 2025

Had a lot of trouble with memory faults from nullpointers and finally figured out that I was using tactics that exist in the Python bindings but not the Rust bindings, namely "qfbv-new-sls"...

#[test]
    fn test_rust_z3_tactics(){
	let tactic = "qfbv-new-sls";
	let config = Config::new();
	let ctx: Context = Context::new(&config);

	//try to create a tactic from qfbv-new-sls if it exists
	let tactic : Tactic = Tactic::new(&ctx, tactic);
    }

results in

process didn't exit successfully: bin_name-a855b6c22e6f17f2 test_rust_z3_tactics --nocapture (signal: 11, SIGSEGV: invalid memory reference)

when we might expect to see an issue printed back to the user or something instead of this kind of failure. i think a check in z3_sys when we are making the new tactic to see if it returns a nullpointer back could help but I'm new to Rust so I'm not positive what the best fix might be

@bakerk98 bakerk98 changed the title Creating a tactic from an invalid tactic results in a SIGSEV Creating a tactic from an invalid tactic results in a SIGSEGV Mar 21, 2025
@Pat-Lafon
Copy link
Contributor

If you want a drive-by suggestion, I would start at

unsafe { Self::wrap(ctx, Z3_mk_tactic(ctx.z3_ctx, tactic_name.as_ptr())) }

Hoist out the Z3_mk_tactic into it's own line and then check whether it is null. From there you can panic with a message or something like that.

z3.rs/z3/src/ast.rs

Lines 576 to 578 in 4f9fcfe

if numeral_ptr.is_null() {
return None;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants