Discussion:
Try this with a signal handler
(too old to reply)
Bonita Montero
2024-06-12 15:29:37 UTC
Permalink
#include <Windows.h>
#include <iostream>
#include <intrin.h>

using namespace std;

int main()
{
__try
{
__debugbreak();
cout << "hello world" << endl;
}
__except( []( EXCEPTION_POINTERS &ep )
{
ep.ContextRecord->Rip += 1;
return EXCEPTION_CONTINUE_EXECUTION;
}( *GetExceptionInformation() ) )
{
}
}

Try this with a signal handler, or you may prefer suicide.
Sam
2024-06-13 03:40:09 UTC
Permalink
Post by Bonita Montero
#include <Windows.h>
#include <iostream>
#include <intrin.h>
using namespace std;
int main()
{
__try
{
__debugbreak();
cout << "hello world" << endl;
}
__except( []( EXCEPTION_POINTERS &ep )
{
ep.ContextRecord->Rip += 1;
return EXCEPTION_CONTINUE_EXECUTION;
}( *GetExceptionInformation() ) )
{
}
}
Try this with a signal handler, or you may prefer suicide.
I regret to inform you the unfortunate fact that you have confused
comp.lang.c++ with Stackoverflow. It is the latter where this exact solution
is often offered as a cure-all that remedies all kinds of undefined behavior.

Your cooperation in ensuring that comp.lang.c++ remains unaffected by
Stackoverflow is greatly appreciated.
Bonita Montero
2024-06-13 07:39:35 UTC
Permalink
Post by Sam
Post by Bonita Montero
#include <Windows.h>
#include <iostream>
#include <intrin.h>
using namespace std;
int main()
{
    __try
    {
        __debugbreak();
        cout << "hello world" << endl;
    }
    __except( []( EXCEPTION_POINTERS &ep )
        {
            ep.ContextRecord->Rip += 1;
            return EXCEPTION_CONTINUE_EXECUTION;
        }( *GetExceptionInformation() ) )
    {
    }
}
Try this with a signal handler, or you may prefer suicide.
I regret to inform you the unfortunate fact that you have confused
comp.lang.c++ with Stackoverflow. It is the latter where this exact
solution is often offered as a cure-all that remedies all kinds of
undefined behavior.
Your cooperation in ensuring that comp.lang.c++ remains unaffected by
Stackoverflow is greatly appreciated.
It's C++ because I'm using a lambda, dude.
Sam
2024-06-14 12:01:12 UTC
Permalink
Post by Bonita Montero
Post by Sam
Post by Bonita Montero
#include <Windows.h>
#include <iostream>
#include <intrin.h>
using namespace std;
int main()
{
    __try
    {
        __debugbreak();
        cout << "hello world" << endl;
    }
    __except( []( EXCEPTION_POINTERS &ep )
        {
            ep.ContextRecord->Rip += 1;
            return EXCEPTION_CONTINUE_EXECUTION;
        }( *GetExceptionInformation() ) )
    {
    }
}
Try this with a signal handler, or you may prefer suicide.
I regret to inform you the unfortunate fact that you have confused
comp.lang.c++ with Stackoverflow. It is the latter where this exact solution
is often offered as a cure-all that remedies all kinds of undefined behavior.
Your cooperation in ensuring that comp.lang.c++ remains unaffected by
Stackoverflow is greatly appreciated.
It's C++ because I'm using a lambda, dude.
Captain Obvious to the rescue!

I /was/ talking about the C++ tag. What did you think I was referring to?
Python?

Bonita Montero
2024-06-13 15:50:02 UTC
Permalink
Interestingly this wasn't so complicated with signals:

#include <iostream>
#include <signal.h>
#include <ucontext.h>

using namespace std;

int main()
{
struct sigaction action;
action.sa_sigaction = []( int signal, siginfo_t *pSi, void *arg )
{
((ucontext_t *)arg)->uc_mcontext.gregs[REG_RIP] += 1;
};
action.sa_flags = SA_SIGINFO;
sigaction( SIGSEGV, &action, NULL );
asm volatile ( "cli" );
cout << "hello world" << endl;
}

Unfortunately all threads share the same signal handler.
SEH is much more convenient.
Loading...