Skip to content

core: guard null central particle in bond breakage angle branch (bug-sweep #26)#5360

Draft
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-26-bondbreakage-null-vs-revert
Draft

core: guard null central particle in bond breakage angle branch (bug-sweep #26)#5360
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-26-bondbreakage-null-vs-revert

Conversation

@RudolfWeeber

Copy link
Copy Markdown
Contributor

The REVERT_BIND_AT_POINT_OF_COLLISION angle-bond branch of
actions_for_breakage guarded only the two partner particles
(if (p1 and p2)) and then dereferenced vs->is_virtual() without
checking vs != nullptr. The global breakage queue is broadcast to
every MPI rank, so each rank runs actions_for_breakage for every
entry, including entries whose central virtual-site particle is not
local/ghost on this rank. On a rank where both partners resolve but
the central particle does not, get_local_particle(e.particle_id)
returns nullptr and vs->is_virtual() is a null dereference (SIGSEGV).

Fix: guard with if (vs and p1 and p2), mirroring the pair branch which
already guards its central particle. Absence-on-rank is a legitimate
locality condition, so the branch returns an empty action set rather
than throwing.

To make the function unit-testable, de-static actions_for_breakage and
declare it in bond_breakage.hpp (the Action/ActionSet aliases move to
actions.hpp). Adds a regression test that reproduces the locality
condition on a single rank (partners present, central absent).

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

🤖 Generated with Claude Code

…sweep #26)

The REVERT_BIND_AT_POINT_OF_COLLISION angle-bond branch of
actions_for_breakage guarded only the two partner particles
(if (p1 and p2)) and then dereferenced vs->is_virtual() without
checking vs != nullptr. The global breakage queue is broadcast to
every MPI rank, so each rank runs actions_for_breakage for every
entry, including entries whose central virtual-site particle is not
local/ghost on this rank. On a rank where both partners resolve but
the central particle does not, get_local_particle(e.particle_id)
returns nullptr and vs->is_virtual() is a null dereference (SIGSEGV).

Fix: guard with if (vs and p1 and p2), mirroring the pair branch which
already guards its central particle. Absence-on-rank is a legitimate
locality condition, so the branch returns an empty action set rather
than throwing.

To make the function unit-testable, de-static actions_for_breakage and
declare it in bond_breakage.hpp (the Action/ActionSet aliases move to
actions.hpp). Adds a regression test that reproduces the locality
condition on a single rank (partners present, central absent).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RudolfWeeber

Copy link
Copy Markdown
Contributor Author

I think this is legit, although it is not obvious to me, how to trigger it from Python.

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.

1 participant