Skip to content

[Bug] ImHex crashes if variable in attribute parameter is not defined at runtime. #2173

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

Open
1 task done
paxcut opened this issue Mar 18, 2025 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@paxcut
Copy link
Collaborator

paxcut commented Mar 18, 2025

Operating System

Windows

What's the issue you encountered?

As a simple example consider the following pattern

#pragma example 00
struct Test {
    u8 a;
    //u8 float_array[5];
}[[hex::visualize("line_plot", float_array)]];

Test t@0;

with input file defined as the pragma example.
With the comment ImHex works as usual, but remove the comment and ImHex will crash with error :

[04:47:38] [FATAL] [main | Evaluating...]      N2pl4core3err12RuntimeErrorINS0_8LocationEE9ExceptionE()::what() -> runtime error: No variable named 'float_array' found.

This error occurs with any attribute that has at least one argument and the argument is undefined at runtime but defined at compile time.
Note that the error should be that data was read past the end of the file but that error is skipped.

The stack trace shows the same line that is executed when the variable is undefined at compile time. If the variable was defined at compile time then it should generate an error saying that the variable extended past the end instead of the undefined variable error.

[04:47:41] [FATAL] [main | Evaluating...]        (??) | pl::core::err::RuntimeError<pl::core::Location>::throwError(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, pl::core::err::UserData<pl::core::Location>) const
[04:47:41] [FATAL] [main | Evaluating...]        (??) | pl::core::ast::ASTNodeRValue::createPatterns(pl::core::Evaluator*, std::vector<std::shared_ptr<pl::ptrn::Pattern>, std::allocator<std::shared_ptr<pl::ptrn::Pattern>>>&) const
[04:47:41] [FATAL] [main | Evaluating...]        (??) | pl::core::ast::ASTNodeRValue::evaluate(pl::core::Evaluator*) const
[04:47:41] [FATAL] [main | Evaluating...]        (??) | pl::core::ast::applyTypeAttributes(pl::core::Evaluator*, pl::core::ast::ASTNode const*, std::shared_ptr<pl::ptrn::Pattern> const&)
[04:47:41] [FATAL] [main | Evaluating...]        (??) | pl::core::ast::ASTNodeStruct::ASTNodeStruct(pl::core::ast::ASTNodeStruct const&)
[04:47:41] [FATAL] [main | Evaluating...]        (??) | pl::core::ast::ASTNodeStruct::createPatterns(pl::core::Evaluator*, std::vector<std::shared_ptr<pl::ptrn::Pattern>, std::allocator<std::shared_ptr<pl::ptrn::Pattern>>>&) const
[04:47:41] [FATAL] [main | Evaluating...]        (??) | pl::core::ast::ASTNodeStruct::createPatterns(pl::core::Evaluator*, std::vector<std::shared_ptr<pl::ptrn::Pattern>, std::allocator<std::shared_ptr<pl::ptrn::Pattern>>>&) const

Is this perhaps a consequence of allowing the evaluator to create patterns on errors? Maybe the error is not being saved when there is a pattern created.

How can the issue be reproduced?

Run the pattern described above on an input file that has one zero byte.

ImHex Version

1.38.0 wip

ImHex Build Type

  • Nightly or built from sources

Installation type

local build

Additional context?

No response

@paxcut paxcut added the bug Something isn't working label Mar 18, 2025
@paxcut paxcut changed the title [Bug] ImHex crashes if variable in attribute is not defined at runtime. [Bug] ImHex crashes if variable in attribute parameter is not defined at runtime. Mar 18, 2025
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

1 participant