Skip to content

Fix SIGSEGV with unsupported atom types in SDF ligands#180

Open
caic99 wants to merge 4 commits into
dptech-corp:mainfrom
caic99:fix/sdf-atom-type-validation-138
Open

Fix SIGSEGV with unsupported atom types in SDF ligands#180
caic99 wants to merge 4 commits into
dptech-corp:mainfrom
caic99:fix/sdf-atom-type-validation-138

Conversation

@caic99
Copy link
Copy Markdown
Member

@caic99 caic99 commented Apr 10, 2026

Summary

  • Adds atom type validation to parse_sdf_atom_string() in parse_pdbqt.cpp, matching the existing check in parse_pdbqt_atom_string()
  • Prevents segfault when SDF files contain unsupported elements (e.g., boron "B") that return AD_TYPE_SIZE sentinel, causing out-of-bounds grid access
  • Adds missing is_non_ad_metal_name() check for non-AD metal types in SDF parser

Root Cause

parse_sdf_atom_string() did not validate atom types. When an SDF contains boron or other unsupported elements, string_to_ad_type("B") returns AD_TYPE_SIZE (35). The atom was added to the model without validation, and later grid evaluation accessed m_grids[35] out of bounds, causing a segfault.

The PDBQT parser already had this validation via acceptable_type() + struct_parse_error, but the SDF parser was missing it entirely.

Test plan

  • Dock an SDF file containing boron atoms — should now skip the ligand with an error message instead of crashing
  • Dock a normal SDF file — should work exactly as before
  • Verify PDBQT docking is unaffected

Fixes #138

🤖 Generated with Claude Code

…ron)

Add atom type validation to parse_sdf_atom_string() matching the existing
check in parse_pdbqt_atom_string(). Without this, unsupported elements like
boron return AD_TYPE_SIZE (sentinel value 35) from string_to_ad_type(),
leading to out-of-bounds grid access and a segfault. Now the parser throws
a struct_parse_error so the ligand is skipped gracefully.

Also adds the is_non_ad_metal_name() check for non-AD metal types, which
was similarly missing from the SDF parser.

Fixes dptech-corp#138

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
caic99 and others added 2 commits April 10, 2026 01:34
Miniforge 26.x (released Feb 2026) ships Python 3.13 by default,
but the openbabel conda-forge package only has builds up to Python
3.12. This caused the "install tools" step to fail for all PRs.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@caic99 caic99 marked this pull request as ready for review April 20, 2026 10:38
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 this pull request may close these issues.

Segmentation Fault (Core Dumped)

1 participant