libpeconv
libpeconv copied to clipboard
in tests, the code "Exception captured by the caller" never been trigger。
My environment:
- windows 11: 22000.2295
- Visuall C++ 2022 Comunity
- cmake
I run the tests by : tests.exe 18 test_case7\test_case7.exe
.
I got the outputs:
Trying to set up exceptions: test_case7\test_case7.exe
[+] Found exception table of: 126 entries
[+] Valid exception entries: 126 entries
[+] The exception table was added
tests::test_load_with_exception_table: Throwing exception:
Calling entry point:
make_exception1: Throwing exception:
Exception handled: STATUS_BREAKPOINT
make_exception2: Throwing exception:
Exception handled: STATUS_INTEGER_DIVIDE_BY_ZERO
Then the tests.exe exit. but "Exception captured by the caller" has never been triggered.
If i add a new function in test_case7:
void make_exception3()
{
std::cout << __FUNCTION__ << ": Throwing exception and not catch:" << std::endl;
RaiseException(STATUS_INTEGER_DIVIDE_BY_ZERO, 0, 0, 0);
}
Then the tests.exe captured the new excption.
So, is this a bug?
PS:I'm sorry for my English, I used a translation tool.
hi @k1988 ! No, this is not a bug, the output looks valid. The test_case7 is supposed to demonstrate that the exceptions thrown from the manually loaded module can be captured by this module. They are not supposed to be captured by tests.exe, but by the exception handlers within the test_case7. So, for example:
void make_exception2()
{
std::cout << __FUNCTION__ << ": Throwing exception:" << std::endl;
__try {
RaiseException(STATUS_INTEGER_DIVIDE_BY_ZERO, 0, 0, 0); // here we throw an exception
}
__except (EXCEPTION_EXECUTE_HANDLER) {
std::cout << "Exception handled: STATUS_INTEGER_DIVIDE_BY_ZERO" << std::endl; // the appropriate handler should be found and executed
}
}
The exception handler comes in the __except
block, and if everything is ok, it should be found and executed. And indeed your output shows a message proving that it was executed.
In your case (make_exception3
), you added one more exception, and you didn't create any handler for it. Your exception is not in any try-except
block. That's why no handler could be found in the test_case7, and it got passed to test.exe. It is a normal situation, and not a bug.