Segmentation fault when expanding HELM with comma-separated monomers
- Dominant language
- C++
- Stars
- 406
- Forks
- 134
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 24
Description
**Summary**
When a HELM string containing a comma (,) is loaded into Indigo and expandedMonomersToAtoms() is called, Indigo does not raise an IndigoException. Instead, it terminates the Python process.
The issue occurs both in a standalone Python script and in a Jupyter Notebook kernel.
**Steps to Reproduce**
Run the following script using a valid path to the Ketcher monomer library:
```
indigo = Indigo()
library = indigo.loadMonomerLibraryFromFile(str("path/to/Ketcher/monomers/library"))
helm = "PEPTIDE1{[ac].(E,[dE])}$$$$V2.0"
helm_doc = indigo.loadHelm(helm, library)
mol_temp = indigo.loadMolecule(helm_doc.json())
mol = mol_temp.expandedMonomersToAtoms()
```
**Actual behavior**
- The process crashes with the following console output:
> Segmentation fault (core dumped)
- No IndigoException is raised when script is executed.
**Expected behavior:**
Indigo should handle the HELM input safely. Depending on whether the HELM string is valid and supported, Indigo should either:
- successfully return the expanded molecule; or
- raise an IndigoException with a descriptive validation or parsing error.
**Environment details:**
- Indigo version: 1.48.0.dev1
- Python version: 3.12.11
- OS version: Ubuntu 24.04.3 LTS running under WSL2 on Windows 11 Enterprise version 25H2
**Additional context:**
The Jupyter kernel crashes during execution of cell with code snippet mentioned above. The displayed message is similar to:
> The Kernel crashed while executing code in the current cell or a previous cell.
Please review the code in the cell(s) to identify a possible cause of the failure.
Click [here](https://github.com/microsoft/vscode-jupyter/wiki/Kernel-crashes) for more info.
View Jupyter log for further details.
The Jupyter log does not contain additional diagnostic information. It only indicates that the kernel process terminated:
> 11:34:32.648 [error] Disposing session as kernel process died ExitCode: undefined, Reason:
11:34:37.636 [error] Error in execution (get message for cell) Error: The kernel 'indigo-from-wheel (3.12.11) (Python 3.12.11)' died. Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. View Jupyter [log](command:jupyter.viewOutput) for further details.
> Kernel Id = ....
> originalException = undefined
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the crash with the reported loadHelm, loadMolecule, and expandedMonomersToAtoms calls using the comma-separated HELM string, both from a Python script and, if useful, Jupyter. Trace the expansion entry point and add coverage for this input. Done means the process no longer segfaults and Indigo either returns a molecule or raises a descriptive IndigoException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100