Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer corruption that is still happening on run() #64

Merged
merged 6 commits into from
Jan 18, 2024

Conversation

figuerom16
Copy link
Contributor

@figuerom16 figuerom16 commented Jan 15, 2024

Buffer corruption was still happening due to the use of Append instead of Copy. Copy is more precise.

I've tried to make an if statement to skip the Copying on when leftover is length zero, but for some reason it always adds back in corruption. I'm really not sure why other than deeper memory handling that I'm not seeing.

@figuerom16
Copy link
Contributor Author

The append implementation strangely works just not the original version.

term.go Show resolved Hide resolved
term.go Outdated Show resolved Hide resolved
@figuerom16
Copy link
Contributor Author

figuerom16 commented Jan 16, 2024

Ok, I think I understand what's going on now! So no matter what the buffer needs to copied every time which is what append is doing essentially. If something modifies the buffer in t.handleOutput then it will be corrupted upon return.

Unless we hunt down what's changing the buffer in t.handleOutput it will need to be copied every time.
EDIT: If I had to guess it might be utf8.DecodeRune(buf) doing something to the buffer memory. I don't see an easy way around that though.

@figuerom16
Copy link
Contributor Author

This is the best/simplest implementation I can find. Luckily it's simpler than the previous implementation. Someone who is more knowledgeable about buffer handling can probably optimize this. Sorry, I couldn't remove the buffer copy.

@figuerom16
Copy link
Contributor Author

Increased buffer size to 32KB to fit in most L1 cache the 4KB buffer is an old I/O standard for files on old hardware.
This will reduce refreshes and buffer copies.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Thanks for hunting this down

@andydotxyz andydotxyz merged commit 35e2bb2 into fyne-io:master Jan 18, 2024
5 checks passed
@figuerom16 figuerom16 deleted the fix-improper-buffer-joining branch January 19, 2024 20:34
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.

2 participants