Skip to content

Fix intermittent SIGSEGV from NaN/non-unit axis in angle_to_quaternion#179

Open
caic99 wants to merge 1 commit intodptech-corp:mainfrom
caic99:fix/quaternion-nan-guard-160
Open

Fix intermittent SIGSEGV from NaN/non-unit axis in angle_to_quaternion#179
caic99 wants to merge 1 commit intodptech-corp:mainfrom
caic99:fix/quaternion-nan-guard-160

Conversation

@caic99
Copy link
Copy Markdown
Member

@caic99 caic99 commented Apr 10, 2026

Summary

Root cause: angle_to_quaternion(axis, angle) assumes the axis is a unit vector, but floating-point precision drift from GPU matrix-vector multiplication (segment transformations in tree.h) can produce non-unit or NaN axes. The existing assert() is stripped in release builds, leaving no protection.

Fix: Add robust handling:

  • NaN or zero-length axis → return identity quaternion (no rotation)
  • Near-unit axis → renormalize before use
  • Well-behaved axis → unchanged behavior

This makes the function resilient to floating-point drift without changing docking results for well-behaved inputs.

Test plan

  • Build with CUDA and verify compilation
  • Run large-scale docking (15k+ ligands) → should not crash with quaternion error
  • Verify docking results are unchanged for normal inputs

🤖 Generated with Claude Code

@caic99 caic99 marked this pull request as ready for review April 20, 2026 10:37
…ternion (dptech-corp#160)

angle_to_quaternion(axis, angle) assumed the axis is a unit vector, but
GPU floating-point precision drift in matrix-vector multiplication
(segment transformations in tree.h) can produce non-unit or NaN axes.
The existing assert() is stripped in release builds, leaving no
protection and causing intermittent crashes.

Add robust handling:
- NaN or zero-length axis: return identity quaternion (no rotation)
- Near-unit axis: renormalize before use
- Well-behaved axis: unchanged behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@caic99 caic99 force-pushed the fix/quaternion-nan-guard-160 branch from e60b4cc to 5158c69 Compare April 20, 2026 10:37
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.

Sometimes "angle_to_quaternion axis.norm=-nan, failed"

1 participant