Skip to content

fix: keep the status bar text alive until the frame is rendered - #125

Open
gustawdaniel wants to merge 1 commit into
freref:masterfrom
gustawdaniel:fix/status-bar-arena
Open

gustawdaniel wants to merge 1 commit into
freref:masterfrom
gustawdaniel:fix/status-bar-arena

Conversation

@gustawdaniel

Copy link
Copy Markdown

drawStatusBar formats its items into self.arena and prints them, so the status bar cells hold slices into the arena. It then reset the arena on return (defer _ = self.arena.reset(.retain_capacity), from #102), before vx.render compares those cells with the previous frame.

When the arena has grown past one buffer, reset(.retain_capacity) frees the other buffers and may move the remaining one to its new size, so the cells point to freed memory. In a debug build that is a segfault in Vaxis.render → InternalCell.eql → mem.eql; in a release build, garbage or a crash. I hit it repeatedly while scrolling quickly with a trackpad, which runs many frames in a row.

The run loop already resets the arena after vx.render, so the reset in drawStatusBar can simply go. The text then lives exactly until the frame has been rendered.

drawStatusBar formats its items into the arena and prints them, so the
screen cells point into the arena, but it reset the arena on return,
before vx.render compares the cells. When the arena had grown past one
buffer, the reset freed the memory the cells pointed to, and Vaxis.render
crashed in InternalCell.eql (segfault in debug builds, where freed pages
are unmapped). The run loop already resets the arena after rendering.

This branch has not been deployed

No deployments
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