Skip to content

Re-evaluate the visualized variable's address on refresh - #518

Open
tiresiasfromthebai wants to merge 1 commit into
epasveer:mainfrom
tiresiasfromthebai:fix-visualizer-stale-address
Open

Re-evaluate the visualized variable's address on refresh#518
tiresiasfromthebai wants to merge 1 commit into
epasveer:mainfrom
tiresiasfromthebai:fix-visualizer-stale-address

Conversation

@tiresiasfromthebai

Copy link
Copy Markdown
Contributor

Problem

The Array and Matrix visualizers evaluate the variable's address only
when the name is typed. Every refresh — the manual button as well as the
auto-refresh at each stop (#496/#498) — then re-reads memory at that
stored address, and never re-evaluates the name. So whenever the
variable's address changes, the plot silently shows stale (or wrong)
memory, and no amount of refreshing heals it:

  • Enter &pos[0] for a std::vector before it is constructed (e.g.
    before Run, or at an early breakpoint): the address evaluates to 0x0
    and is trapped forever — every subsequent stop re-reads address 0 and
    pops "Unable to read memory", even though the vector now exists.
  • A vector that reallocates (push_back, resize) between two stops: the
    visualizer keeps plotting the old buffer — plausible-looking but
    dead data, with no error at all.
  • Same story after a re-Run of the program (fresh stack/heap addresses).

Fix

Split the refresh in two steps. The refresh handlers now re-evaluate the
variable name, and the ^done answer reads the memory at the fresh
address (new readaMemory()/readbMemory()/readMemory() holding the
previous read logic). Since every refresh path funnels through the same
handlers — the manual Refresh button, the auto-refresh at each stop, and
the length/rows/columns/offset/stride changes — they all pick up the
fresh address now. A nice side effect: re-typing the name while
stopped refreshes the plot immediately, instead of only updating the
address field.

The read step is skipped for a null address or an empty length: a
not-yet-constructed variable now shows its 0x0 address quietly and the
plot simply appears at the first stop where the variable exists, instead
of raising a memory error at every interaction.

Testing

Qt 6.4.2, Linux Mint. With a 4000-point std::vector phase portrait
(scatter, Auto checked):

  1. Enter &pos[0]/&vit[0] at an early breakpoint (vectors not yet
    constructed), address shows 0x0 → Continue to the filling
    breakpoint, or simply hit Refresh: the address updates and the plot
    appears (previously: "Unable to read memory" on every stop and every
    refresh, forever).
  2. Normal flow (names entered at a healthy breakpoint): stepping and
    Continue refresh exactly as before.
  3. Matrix Visualizer: same two scenarios on an Eigen matrix.
  4. Line/spline/scatter modes unaffected.
Capture d’écran du 2026-08-13 13-42-58 Capture d’écran du 2026-08-13 13-43-17

The Array and Matrix visualizers evaluated the variable's address only
when the name was typed; every refresh then re-read memory at that
stored address forever. A stale address (a vector entered before its
construction, a reallocation, a re-run) kept being read — errors at
best, plausible-looking dead data at worst.

Split the refresh in two: the refresh handlers now re-evaluate the
variable name, and the answer reads the memory at the fresh address
(readaMemory/readbMemory/readMemory). Every refresh path — the manual
button, the auto-refresh at each stop, and the length/offset/stride
changes — now goes through the re-evaluation. The read is skipped for a
null address or an empty length, so a not-yet-constructed variable shows
its 0x0 address quietly instead of raising memory errors.
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