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

Exception handler gets eliminated #4716

Closed
fuzyll opened this issue Oct 27, 2023 Discussed in #4693 · 1 comment
Closed

Exception handler gets eliminated #4716

fuzyll opened this issue Oct 27, 2023 Discussed in #4693 · 1 comment
Labels
Component: Core Issue needs changes to the core Effort: Low Issue should take < 1 week Impact: Medium Issue is impactful with a bad, or no, workaround State: Duplicate Issue is a duplicate of another issue Type: Bug Issue is a non-crashing bug with repro steps

Comments

@fuzyll
Copy link
Contributor

fuzyll commented Oct 27, 2023

Created this issue from this discussion.

See code below. When we decompile this, we actually lose the entire catch branch somehow and don't decompile it. Part of the problem is that we mark the mightThrow() function as noreturn, but even if you mark the function as able to return, it still skips over the exception handler. I haven't looked closely enough to figure out why.

The compiled executable I made is attached:

exception_test.zip

Originally posted by oskarwirga October 19, 2023
Exceptions are hard I know but analyzing the try catch in main this isn't quite supported in any decompiler that I've seen.

#include <iostream>
#include <stdexcept>

int mightThrow(){
    std::cout << "Throwing an exception...\n";
    throw std::runtime_error("This is a runtime error exception!");
}

int main(int argc, char** argv) {
    if (argc > 2){
        try {
            mightThrow();
        } catch (const std::exception& e) {
            std::cout << "Caught an exception: " << e.what() << "\n";
        }
    }
    return 0;
}
@fuzyll fuzyll changed the title Does Binary Ninja support C++ Exception Handling? Exception handler gets eliminated Oct 27, 2023
@fuzyll fuzyll added Type: Bug Issue is a non-crashing bug with repro steps Component: Core Issue needs changes to the core Effort: Low Issue should take < 1 week Impact: Medium Issue is impactful with a bad, or no, workaround labels Oct 27, 2023
@plafosse plafosse added the State: Duplicate Issue is a duplicate of another issue label Nov 7, 2023
@plafosse
Copy link
Member

plafosse commented Nov 7, 2023

Closing as duplicate of #9

@plafosse plafosse closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Issue needs changes to the core Effort: Low Issue should take < 1 week Impact: Medium Issue is impactful with a bad, or no, workaround State: Duplicate Issue is a duplicate of another issue Type: Bug Issue is a non-crashing bug with repro steps
Projects
None yet
Development

No branches or pull requests

2 participants