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

Segmentation fault on invalid SMARTS in RWMol::from_smarts() #18

Open
aleebberg opened this issue Dec 2, 2023 · 1 comment · May be fixed by #19
Open

Segmentation fault on invalid SMARTS in RWMol::from_smarts() #18

aleebberg opened this issue Dec 2, 2023 · 1 comment · May be fixed by #19

Comments

@aleebberg
Copy link

aleebberg commented Dec 2, 2023

I am still new to Rust as well as to rdkit, but I am having some problems with the conversion of SMARTS to RWMol. I hope you can help me with this.

I work on Mac and use a normal cargo binary crate. My code is very simple. I pass an invalid SMARTS to RWMol::from_smarts() and try to unwrap it. However, instead of having the code throw an error or panic, the execution gets interrupted and I get a segmentation fault:

let invalid_rwmol = RWMol::from_smarts("abdi###bhd").unwrap(); // just an arbitrary string
println!("{:?}", invalid_rwmol);

I first started with matching the Result, but it would always come out as Ok(). When I debugged my code I noted that, although the method returned Ok(), the value of the RWMol pointer was null. However the pointer of the RWMol struct is private to the rdkit-crate so I cannot access it to see, if it is null. Also, since RWMol::from_smarts returns a Result<RWMol, Box>, I dont think it is the expected behavior.

The actual goal of my code was to check if some SMARTS I built are valid by simply creating a Mol-Struct out of them. If the SMARTS is not valid, I wanted to match the Err(). In Python this was easy, as Chem.MolFromSmarts() simply returns None if it wasn't successfull and I could go on form there.

As I am doing this as part of my Master's thesis, I would be very grateful for your help!

@aleebberg aleebberg linked a pull request Dec 4, 2023 that will close this issue
@aleebberg
Copy link
Author

So I opened a PR to try to fix this problem.
@JJ-Pineda I would be very grateful, if you could check it out.

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

Successfully merging a pull request may close this issue.

1 participant