All of lore.kernel.org
 help / color / mirror / Atom feed
* Catching SIGSEGV with signal() in 2.6
@ 2004-04-05 15:25 bero
  2004-04-05 18:17 ` Jamie Lokier
  0 siblings, 1 reply; 14+ messages in thread
From: bero @ 2004-04-05 15:25 UTC (permalink / raw)
  To: linux-kernel

... doesn't seem to be possible anymore.

See
http://www.openoffice.org/issues/show_bug.cgi?id=27162

Is this change intentional, or a bug?

LLaP
bero

-- 
Ark Linux - Linux for the masses
http://www.arklinux.org/

Redistribution and processing of this message is subject to
http://www.arklinux.org/terms.php

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Catching SIGSEGV with signal() in 2.6
@ 2004-04-06  0:40 Kevin B. Hendricks
  2004-04-06  2:04 ` Ulrich Drepper
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin B. Hendricks @ 2004-04-06  0:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: bero

Hi,

Just in case this helps,  this is a simplified testcase of the OpenOffice.org 
code in question that always worked under 2.4 kernels on multiple 
architectures but fails on 2.6.X kernels on those same multiple platforms.

For some reason, the segfault generated by trying to write to address 0 can 
not be properly caught anymore (or at least it appears that way to me).

Hope this helps.

Kevin

[kbhend@base1 solar]$ cat testcase.c
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>

typedef int (*TestFunc)( void* );
static jmp_buf check_env;
static int bSignal;

void SignalHdl( int sig )
{
  bSignal = 1;
  longjmp( check_env, sig );
}

int check( TestFunc func, void* p )
{
  int result;
  bSignal = 0;
  if ( !setjmp( check_env ) )
  {
        signal( SIGSEGV,        SignalHdl );
        signal( SIGBUS,         SignalHdl );
        result = func( p );
        signal( SIGSEGV,        SIG_DFL );
        signal( SIGBUS,         SIG_DFL );
  }
  if ( bSignal )
        return -1;
  else
        return 0;
}

int GetAtAddress( void* p )
{
  return *((char*)p);
}

int SetAtAddress( void* p )
{
  return *((char*)p)    = 0;
}

int CheckGetAccess( void* p )
{
  int b;
  b = -1 != check( (TestFunc)GetAtAddress, p );
  return b;
}

int CheckSetAccess( void* p )
{
  int b;
  b = -1 != check( (TestFunc)SetAtAddress, p );
  return b;
}

void InfoMemoryAccess( char* p )
{
  if ( CheckGetAccess( p ) )
    printf( "can read address %p\n", p );
  else
    printf( "can not read address %p\n", p );

  if ( CheckSetAccess( p ) )
    printf( "can write address %p\n", p );
  else
    printf( "can not write address %p\n", p );
}

int
main( int argc, char* argv[] )
{
  {
        char* p = NULL;
        InfoMemoryAccess( p );
        p = (char*)&p;
        InfoMemoryAccess( p );
  }
  exit( 0 );
}



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-04-06 15:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-05 15:25 Catching SIGSEGV with signal() in 2.6 bero
2004-04-05 18:17 ` Jamie Lokier
2004-04-05 19:16   ` Chris Friesen
2004-04-05 20:40     ` Jamie Lokier
2004-04-05 20:59       ` Richard B. Johnson
2004-04-05 21:11         ` Chris Friesen
2004-04-05 21:12         ` Jamie Lokier
2004-04-05 21:23   ` bero
  -- strict thread matches above, loose matches on Subject: below --
2004-04-06  0:40 Kevin B. Hendricks
2004-04-06  2:04 ` Ulrich Drepper
2004-04-06  3:01   ` Kevin B. Hendricks
2004-04-06  4:08     ` Ulrich Drepper
2004-04-06 12:02       ` Kevin B. Hendricks
2004-04-06 15:53       ` Edgar Toernig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.