WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
https://imhex.werwolv.net
GNU General Public License v2.0
44.59k stars 1.95k forks source link

[Bug] Crash When File is Updated #1485

Closed Vzor- closed 8 months ago

Vzor- commented 9 months ago

Operating System

MacOS

What's the issue you encountered?

On MacOS, when viewing files, imHex occasionally crashes. It only seems to happen when the contents of a file change, and it does not occur every time. This is what the logs catch, but looking at the timestamps, we can see all of this is during startup, and nothing is from the actual crash event. https://gist.github.com/Vzor-/e2a74417d90bc559f48d63fe8d9d30f8

How can the issue be reproduced?

  1. Write a file
  2. Open the file in imHex
  3. Alter the file via some other means, like a text editor (repeat until crash, somewhere around 10 tries)

ImHex Version

1.31.0

ImHex Build Type

Installation type

dmg (amd64 and later arm64)

Additional context?

Ventura 13.0 (amd64 dmg) then Sonoma 14.3 (aarch64 dmg) M1 macbook

On Sonoma, I got a proper crash report https://gist.github.com/Vzor-/194d0b949e518a34d5528fd57111dc3e

WerWolv commented 9 months ago

Hey! Does the size of the file change by any chance? ImHex maps the file into memory using mmap to be able to access it efficiently. The issue with that is that shrinking the file will cause undefined behaviour that's (from my understanding) basically not fixable. This happens on Linux and Windows as well and is a OS limitation.

Afaik, there's basically nothing we can really do about it. You can load the entire file into memory by right clicking the file tab or the search bar and selecting the option in the context menu which would avoid the issue but might not be great for large files

Vzor- commented 9 months ago

No, it occurs regardless. Sorry I edited the issue so much lol, SAMBA was a bit of a red herring.

Vzor- commented 9 months ago

It has become much harder to reproduce the issue, I'm unsure why. The '10 try' note no longer seems apt.

Mootix1313 commented 8 months ago

Just adding on with additional deets. The original title of this issue fits my current situation.


How can the issue be reproduced?

Steps

  1. Start-up imHex.
  2. Select a file to open in imHex.

Details

After attempting to open a file, imHex immediately crashes, which is followed by the Problem Report for... window.

Here, you're given the choice to acknowledge the issue by selecting OK (this closes the session/window), or to try to reopen the program by selecting reopen. imHex reopens just fine. However, if I opt to restore my lost data by selecting Yes, Restore imHex will attempt to do so, but will immediately crash. Sometimes I'll get a very short glimpse of the file I'm trying to open.

Side note, the files I'm trying to open are local to my computer.


ImHex Details

Version Build Type Install Type
1.32.2 latest arm64 dmg

Additional context?

I'm experiencing this issue on a Macbook Pro M1.

Uname Output

$> uname -m -o -r -v

Darwin 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64

Crash Report

WerWolv commented 8 months ago

@Mootix1313 Thanks for the report! This is most likely an unrelated issue. I fixed it in the latest commit now though. Please try the latest nightly of ImHex once it finished building in maybe 20 minutes.

As for the bug this issue was about originally, I've since managed to replace the mmapped memory operations with atomic file IO so this should no longer be a problem now. @Vzor-, please try the latest nightly as well if you can.