Menu

#129 User-set delta time from `GetSyncData` callback could be overwritten when asking redo the step

Unstable (example)
open
nobody
None
5
2026-03-15
2026-03-15
No

In the sharedsync function, user could return 1 and ask to redo the step with a new value of pcktdelta, this works in normal cases.

           int retval = getsync(*pckttime, pcktdelta, olddelta, redostep, ng_ident, loc, userptr);
            /* never move beyond final time */
            if (*pckttime + *pcktdelta > finalt) {
                double newdelta;

                newdelta = finalt - *pckttime - 1.1 * delmin;
                if (newdelta <= 0.0)
                    newdelta = finalt - *pckttime;
                *pcktdelta = newdelta;
            }

            /* user has decided to redo the step, ignoring redostep being set to 0
            by ngspice. */
            if (retval) {
                *pckttime -= olddelta;
                (*rejected)++;
            }
            return retval;

However, if *pckttime + *pcktdelta > finalt is true, it will come into the first branch and then set a new value for pcktdelta, which means the value from user will be overwritten. It is wrong here when retval is 1, as if user asks to redo the step, the actual time will be *pckttime - olddelta, not pckttime and it doesn't mean the time will move beyond final time if *pckttime + *pcktdelta > finalt is true.

A fix I think would be just reorder the first branch and the second branch, i.e. put the check for retval first.

1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB