Skip to content

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

Description

@aleebberg

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions