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

[Bug] Random crash when evaluating pattern #1934

Open
1 task
LeagueRaINi opened this issue Oct 16, 2024 · 8 comments
Open
1 task

[Bug] Random crash when evaluating pattern #1934

LeagueRaINi opened this issue Oct 16, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@LeagueRaINi
Copy link

LeagueRaINi commented Oct 16, 2024

Operating System

Windows

What's the issue you encountered?

ImHex crashes when evaluating patterns seemingly at random

How can the issue be reproduced?

Load the firmware dump, load the pattern and hit evaluate, 50/50 chance it will crash

ImHex Version

1.35.4

ImHex Build Type

  • Nightly or built from sources

Installation type

Portable

Additional context?

Log: 20241016_032838.log
Pattern: persistent_data_pattern.txt

Cant attach a dump of the firmware for legal reasons

@LeagueRaINi LeagueRaINi added the bug Something isn't working label Oct 16, 2024
@paxcut
Copy link
Contributor

paxcut commented Oct 16, 2024

I understand not being able to post sensitive or otherwise restricted materials. In that case, one would invent an artificial file that is both not restricted and that exhibits the bug when used as input for the pattern.

I tried running the pattern on an input with all 0x44 zeroes and also used random values and nothing crashed. Does the file name have special characters in it? The pattern itself is fairly simple and I can't imagine anything in it being the cause but it is hard to tell without a reproducible case.

When you say 50/50 chance it will crash do you mean while it is evaluating the pattern or does it finish and then it crashes when you look at some data or something else? Also it is not clear if ImHex crashes when running the pattern in one particular file or on any valid file of the type. Form the log file it looks like you dont try to evaluate the pattern as it is crashing shortly after loading the layout. Maybe there is data corruption in initialization files. Try renaming them so they are recreated.

@Husamdababneh
Copy link

Husamdababneh commented Oct 21, 2024

@paxcut The samething is happening to me, while talking about it with WerWolv on discord this was his/her exact words in response to this stack trace

[18:43:00] [FATAL] [main | Main] Received signal 'SIGSEGV' (11)
[18:43:00] [INFO] [main | Main] Wrote crash.json file to C:\Users\USER\AppData\Local\imhex\config\crash.json
[18:43:00] [FATAL] [main | Main] Printing stacktrace using implementation 'StackWalk'
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | _C_specific_handler
[18:43:00] [FATAL] [main | Main] (??) | _chkstk
[18:43:00] [FATAL] [main | Main] (??) | RtlFindCharInUnicodeString
[18:43:00] [FATAL] [main | Main] (??) | KiUserExceptionDispatcher
[18:43:00] [FATAL] [main | Main] (??) | hex::ui::PatternDrawer::sortPatterns(ImGuiTableSortSpecs const*, pl::ptrn::Pattern const*, pl::ptrn::Pattern const*) const
[18:43:00] [FATAL] [main | Main] (??) | void std::__insertion_sort<__gnu_cxx::__normal_iterator<pl::ptrn::Pattern**, std::vector<pl::ptrn::Pattern*, std::allocatorpl::ptrn::Pattern*>>, __gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (pl::ptrn::Pattern const*, pl::ptrn::Pattern const*)>>>(__gnu_cxx::__normal_iterator<pl::ptrn::Pattern**, std::vector<pl::ptrn::Pattern*, std::allocatorpl::ptrn::Pattern*>>, __gnu_cxx::__normal_iterator<pl::ptrn::Pattern**, std::vector<pl::ptrn::Pattern*, std::allocatorpl::ptrn::Pattern*>>, __gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (pl::ptrn::Pattern const*, pl::ptrn::Pattern const*)>>)
[18:43:00] [FATAL] [main | Main] (??) | void std::__final_insertion_sort<__gnu_cxx::__normal_iterator<pl::ptrn::Pattern**, std::vector<pl::ptrn::Pattern*, std::allocatorpl::ptrn::Pattern*>>, __gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (pl::ptrn::Pattern const*, pl::ptrn::Pattern const*)>>>(__gnu_cxx::__normal_iterator<pl::ptrn::Pattern**, std::vector<pl::ptrn::Pattern*, std::allocatorpl::ptrn::Pattern*>>, __gnu_cxx::__normal_iterator<pl::ptrn::Pattern**, std::vector<pl::ptrn::Pattern*, std::allocatorpl::ptrn::Pattern*>>, __gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (pl::ptrn::Pattern const*, pl::ptrn::Pattern const*)>>)
[18:43:00] [FATAL] [main | Main] (??) | pl::ptrn::PatternStruct::sort(std::function<bool (pl::ptrn::Pattern const*, pl::ptrn::Pattern const*)> const&)
[18:43:00] [FATAL] [main | Main] (??) | hex::ui::PatternDrawer::beginPatternTable(std::vector<std::shared_ptrpl::ptrn::Pattern, std::allocator<std::shared_ptrpl::ptrn::Pattern>> const&, std::vector<pl::ptrn::Pattern*, std::allocatorpl::ptrn::Pattern*>&, float) const
[18:43:00] [FATAL] [main | Main] (??) | hex::ui::PatternDrawer::draw(std::vector<std::shared_ptrpl::ptrn::Pattern, std::allocator<std::shared_ptrpl::ptrn::Pattern>> const&, pl::PatternLanguage const*, float)
[18:43:00] [FATAL] [main | Main] (??) | hex::plugin::builtin::ViewPatternData::drawContent()
[18:43:00] [FATAL] [main | Main] (??) | hex::View::Window::draw()
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | ??
[18:43:00] [FATAL] [main | Main] (??) | BaseThreadInitThunk
[18:43:00] [FATAL] [main | Main] (??) | RtlUserThreadStart

Response:

It's a race condition somehow. I haven't figured out what exactly is wrong there

To produce the same issue you can use the following

Pattern: elden.txt
Bin File: ER0000.zip

NOTE: extract the zip file

@paxcut
Copy link
Contributor

paxcut commented Oct 21, 2024

@Husamdababneh that may or may not be the same issue as the op reported. Your crash suggests that you are sorting the data as reported in issue #1938 , but the op doesn't mention sorting and doesn't provide a stack trace or ways to produce one.

@Husamdababneh
Copy link

Husamdababneh commented Oct 21, 2024

@paxcut hmm, Acutally there is a log attached to the issue here 20241016_032838.log with the same stack trace that I have as far as I can tell , I'm pretty sure that it's the same issue as #1938.

The issue is when you evaluate the pattern a call to hex::ui::PatternDrawer::sortPatterns method is invoked.

Also, a proof of the issue (race condition) would be that when I try to evaluate the file and it succeed, sometimes the Pattern data window have different ordering

What I'm trying to say that the issue is most noticible when you evaluate the patterns which is the main use of ImHex, but the issue is actually from sorting the values

@paxcut
Copy link
Contributor

paxcut commented Oct 21, 2024

I missed the fact that there was a log attached to the op, and from it it does indeed look like the same bug (I did say may or may nor though). So it looks like the race condition is related to both the evaluation and the sorting of the results. If you don't sort the results the crash doesn't seem to happen and just sorting results seems to work fine (although nothing seems to be changing which is kind of confusing)

@Husamdababneh
Copy link

That's okay I didn't mean anything when I pointed out that the logs exists (it happens to the best of us)

Yes, not sorting the results does not crash, but the issue with pattern evaluation that it does the sorting automatically

@paxcut
Copy link
Contributor

paxcut commented Oct 21, 2024

Yes, not sorting the results does not crash, but the issue with pattern evaluation that it does the sorting automatically

What I meant is that if you don't sort the results you can evaluate the pattern as many times as you want without causing a crash, so even if evaluation sorts automatically that doesn't seem to create a problem unless you sort the data differently from the default sorting. Even if you sort away from default, the error only occurs when some data is accessed by two threads at the same time, or at least, that's my suspicion at the moment.

@LeagueRaINi
Copy link
Author

Completely forgot to respond last time but yeah the sorting theory works out for me as well, after deleting all the configs the crashes are gone and last time they started I did indeed sort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants