Different seh filtering in x86 and x64

99封情书 提交于 2019-12-24 21:20:51

问题


I am implementing logging of error message (It includes information of exception backtrace). I asked similar question how to do this at Reliable way to print exception backtrace in catch handler?. I decided to check out callstacks at x86 and x64 platforms. Result of stack comparisons surprised me. Here is my program:

#include <iostream>
#include <Windows.h>

using namespace std;

struct A
{
};

void foo3()
{
    throw A();
}

void foo2()
{
    foo3(); 
}

void foo1()
{
    foo2();
}

void foo()
{
    try
    {
        foo1();
    }
    catch(...)
    {
        cout << "exception rethrowing" << endl;
        throw;
    }
}
int seh_filter(_EXCEPTION_POINTERS* exception)
{
    cout << "SEH FILTER" << endl;
    return EXCEPTION_EXECUTE_HANDLER;
}

int main(void)
{
    __try
    {
        foo();
    }
    __except(seh_filter(GetExceptionInformation()))
    {
        cout << "SEH catch handler" << endl;
    }
    return 0;
}

I set breakpoint at seh_filter to explore backtrace and ran debug builds. Here is images:

It seems like I cannot print full call stack on x64 platform. What's going on? I cannot understand why were callstacks changed so dramatically? I am using msvc2013 on Windows 10.

来源:https://stackoverflow.com/questions/48985041/different-seh-filtering-in-x86-and-x64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!