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

SIGBUS when viewing a file that is truncated while loading #9

Open
tstack opened this issue Feb 12, 2024 · 0 comments
Open

SIGBUS when viewing a file that is truncated while loading #9

tstack opened this issue Feb 12, 2024 · 0 comments

Comments

@tstack
Copy link

tstack commented Feb 12, 2024

Description

When opening a file that is then truncated, the program crashes with a SIGBUS.

Platform

MacOS 14.3

tl v1.0.0

How to reproduce

The easiest way is to create a large file with a bunch of lines, run tl bigfile.txt. Then, while tl is scanning for new lines, run truncate -s 0 bigfile.txt in another terminal.

Details

Using mmap() on a file the app doesn't own/control is problematic since changes to the file can mess up your process. It would probably be best to avoid mmap() and use regular file I/O instead.

While this may seem unlikely, it can happen in practice because of things like logrotate's copytruncate option which will copy the file contents and then truncate it.

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

No branches or pull requests

1 participant