micro-editor / micro-editor/micro
main.Buffer.ReOpen hangs for large binary files
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
Description of the problem or steps to reproduce
Call main.Buffer.ReOpen on a large binary file (e.g. the micro binary) and observe it hang completely.
You can try this out yourself by installing the filemanager plugin, running the tree command and attempting to open the micro binary with TAB.
Specifications
You can use micro -version to get the commit hash.
Commit hash: de35d00ba7880540074b6ce500bbd1b82e986f61
OS: Ubuntu 18.04.1 LTS
Terminal: GNOME Terminal
Other Information
I've narrowed this down to the String() method of main.LineArray:
This method is called by main.EventHandler.ApplyDiff() (L89)
The issue is that eh.buf (in the case of the micro binary) is about 100k elements long, causing String() to pretty much crash the whole thing.
Attempted Fix
I tried changing this method to use the new strings.Builder but it did not seem to help.
Potential Solution
One potential solution I came up with is checking the equality of the old and new line arrays before diffing them, which is slow (takes maybe 1/4 a second) but doesn't hang micro completely.
This issues causes #1208 (filemanager calls ReOpen when opening a file for some reason).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with cmd/micro/lineArray.go, especially LineArray.String(), then trace how it is called from EventHandler.ApplyDiff in cmd/micro/eventhandler.go. Reproduce the problem through the filemanager plugin by opening a large binary with tree and TAB; done means ReOpen completes without hanging on large binary files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100