Skip to content

Conversation

@SeverinDiederichs
Copy link
Collaborator

This mini PR fixes a bug reported by code analysis from @dkonst13:

The the loop of reducing the step size when stuck on the boundary, the move was adjusted, but the position was not changed. As the move affects the remains and the stepDone, the position must be also adjusted here, otherwise it is not consistent.

@phsft-bot
Copy link

Can one of the admins verify this patch?

@SeverinDiederichs
Copy link
Collaborator Author

CI failed in reproducibility in sync AdePT, a longer standing and rare issue. Just restarted it.

if (!continueIteration) {
// Let's move to the other side of this boundary -- this side we cannot progress !!
move = Navigator_t::kBoundaryPush; // curvedStep
position += move * chordDir;
Copy link
Contributor

@agheata agheata Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure about this: it introduces a semantics change after crossing the boundary; instead of leaving the point on the boundary, it will slightly push it, which may have adverse effects in case of back-scattering. On the other hand, you are right that the stepDone is updated with the move, which makes it inconsistent. I wonder if we should rather not readjust stepDone with this tiny move.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of back scattering, it should never reach that part because of this:

      if (move <= kDistCheckPush) {
#if ADEPT_DEBUG_TRACK > 0
        if (verbose) {
          printf("| BACK-SCATTERING or WRONG RELOCATION detected hitting ");
          next_state.Print();
        }
#endif
        zero_first_step = true;
        return 0.;

But of course I am open to just delete the entire block with

if (!continueIteration) {

because if it doesn't update the position, it doesn't do anything useful. Then we don't even need the continueIteration
either anymore... So definitely in the current state it doesn't do anything useful, we should see how to resolve it, this would be only a quick fix to make it consistent, not to address the whole problem.

It is not super urgent, it doesn't fix stuck tracks, but this should be reviewed and fixed

Copy link
Contributor

@agheata agheata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it looks like the addition is correct and may prevent some undesired lock on boundary. Thanks for the fix!

@agheata agheata merged commit e5aced4 into apt-sim:master Nov 5, 2025
3 checks passed
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.

3 participants