Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Multithreaded MolStandardize *InPlace functions hang with numThreads=0 and race with negative numThreads

Open Beginner friendly
#9,695 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@Ardx19 is already working on this.

Since Oct 9, 2026.

  • #9696 by @Ardx19 — open

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, python

Research direction

The bug is in standardizeMultipleMolsInPlace() in Code/GraphMol/MolStandardize/MolStandardize.cpp, where the worker loop strides by the raw numThreads argument instead of the resolved numThreadsToUse. Read how getNumThreadsToUse is called there, then change the stride to the resolved count. Done when CleanupInPlace(mols, 0) returns and each molecule is processed exactly once, which a regression test in the MolStandardize tests should check.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
The multi-molecule versions of the MolStandardize *InPlace() functions (CleanupInPlace, NormalizeInPlace, TautomerParentInPlace, ...) hang forever when called with numThreads=0 (which elsewhere in the RDKit means "use all available threads"). With negative values (e.g. -1, "all but one") several threads end up processing the same molecules concurrently while most molecules are never processed.

The cause is in standardizeMultipleMolsInPlace() in Code/GraphMol/MolStandardize/MolStandardize.cpp: the number of threads is resolved with getNumThreadsToUse(numThreads), but each worker advances by the raw argument:

for (auto mi = tidx; mi < mols.size(); mi += numThreads) {

With numThreads == 0 the stride is 0; with negative values the unsigned arithmetic wraps around.

To Reproduce

from rdkit import Chem
from rdkit.Chem.MolStandardize import rdMolStandardize

mols = [Chem.MolFromSmiles(smi) for smi in ('CCO', 'c1ccccc1', 'CC(=O)[O-].[Na+]', 'C[N+](=O)[O-]')]
rdMolStandardize.CleanupInPlace(mols, 0)   # never returns (on a machine with >1 hardware thread)

Expected behavior
numThreads=0 should use all available threads and negative values all-but-N, as with other RDKit functions taking numThreads, and each molecule should be processed exactly once.

Configuration (please complete the following information):

  • RDKit version: current master (fece8caa8, 2026.09.1)
  • OS: Ubuntu 22.04 (WSL2)
  • Python version (if relevant): 3.10
  • Are you using conda? Yes, for the build environment
  • If you are not using conda: how did you install the RDKit? Built from source

Additional context
The fix is a one-word change (stride by the resolved thread count, numThreadsToUse); I'm happy to submit a PR with a regression test.

Dominant language
HTML
Stars
3.6k
Forks
1.1k
Avg merge
4d 7h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rdkit/rdkit

All issues in rdkit/rdkit

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.