On 19.03.2012 17:38, Daniel Jacobowitz wrote:
On Mon, Mar 19, 2012 at 12:12 PM, Andrew Stubbs<a...@codesourcery.com> wrote:
On 16/03/12 13:29, EXTERNAL Waechtler Peter (Fa. TCP, CM-AI/PJ-CF31) wrote:
The CodeSourcery toolchain contains a "fix" like the following,
please consider for adding it.
Here's the full original patch with ChangeLog.
I don't know why Dan never submitted this one. Perhaps it's not suitable for
upstream or not considered the correct fix?
I think it was just a pain to write a test for.
Here's another version using siglongjmp to avoid VERIFY in signal handler:
Can someone (maybe you) put that at the appropriate place?
Please don't let the integration being a pain as well
Peter
seehttp://gcc.gnu.org/ml/gcc-patches/2012-03/msg01161.html
/*
author: Peter Waechtler (pwaechtler at mac.com)
Copyright FSF or whatever is needed
A simple test case to verify if backtrace(3) goes into
a loop while unwinding on ARM with cxx_personality routine.
*/
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
#include<signal.h>
#include<execinfo.h>
#include<setjmp.h>
#include<iostream>
#include<vector>
using namespace std;
//#include "testsuite.h"
#define WE_PASSED 42
#define WE_FAILED 0xff
sigjmp_buf env;
static void abort_handler(int n_signal, siginfo_t *siginfo, void *ptr)
{
void *address[20];
int depth;
depth = backtrace(address, sizeof(address)/sizeof(void*));
backtrace_symbols_fd(address, depth, 0);
/* this is a dumb check, better look for main */
if (depth == sizeof(address)/sizeof(void*))
siglongjmp(env, WE_FAILED);
else
siglongjmp(env, WE_PASSED);
}
static int tst_eh01(void)
{
int rc = 0;
std::vector<int> v(10);
rc = v.at(42);
return rc;
}
int main(int argc, char *argv[])
{
int c = 1;
struct sigaction sa;
memset(&sa, 0 , sizeof(sa));
sa.sa_sigaction = abort_handler;
sa.sa_flags = SA_SIGINFO;
sigaction(SIGABRT,&sa, NULL);
switch (sigsetjmp(env, 1)) {
case 0: /* the context was set */
c = tst_eh01();
break;
case WE_PASSED:
// VERIFY( true );
cerr<< "PASSED"<< endl;
break;
default:
// VERIFY( false );
cerr<< "FAILED"<< endl;
break;
}
return c;
}