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

Tautomer Query copy constructor is shallow not deep causing segfaults in destructor #3821

Closed
bp-kelley opened this issue Feb 17, 2021 · 5 comments
Labels
Milestone

Comments

@bp-kelley
Copy link
Contributor

Failing Test (for tautomerQueryTestCatch)

TEST_CASE("TAUTOMERQUERY_COPY_CONSTRUCTOR") {
  auto mol = "c1ccccc1"_smiles;
  auto tautomerQuery =
    std::unique_ptr<TautomerQuery>(TautomerQuery::fromMol(*mol));
  auto tautomerQueryCopyConstructed = std::unique_ptr<TautomerQuery>(new TautomerQuery(*tautomerQuery));
}
@bp-kelley bp-kelley added the bug label Feb 17, 2021
@bp-kelley
Copy link
Contributor Author

@jones-gareth @greglandrum

It appears that the template molecule should be a shared ptr as well:

  const std::vector<ROMOL_SPTR> d_tautomers;
  // Template query for substructure search
  const ROMol *const d_templateMolecule;

should be

  const std::vector<ROMOL_SPTR> d_tautomers;
  // Template query for substructure search
  const boost::shared_ptr<const ROMol*> d_templateMolecule;

However, I remember some compilers not liking shared_ptrs to const pointers.
This does have an issue with threading with TautomerQueries though if we are doing recursive queries and really need a full copy. I would like a way to do a proper deep copy.

@greglandrum
Copy link
Member

Another approach to fixing this which solves the thread safety problem would be keep d_templateMolecule as a naked pointer but to explicitly copy the molecule in the copy constructor for TautomerQuery.

@bp-kelley
Copy link
Contributor Author

Are the tautomers used as well during the search?

@greglandrum
Copy link
Member

ah, right. It's the tautomers that are used during the query, not the template molecule.
I still think it makes sense to do a deep copy of the whole thing in the copy ctor.

@bp-kelley
Copy link
Contributor Author

bp-kelley commented Feb 17, 2021 via email

@greglandrum greglandrum added this to the 2021_03_1 milestone Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants