linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* SPARC and SA_SIGINFO signal handling
@ 2001-10-29 19:00 Christophe Rhodes
  2001-10-30 20:51 ` David S. Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Rhodes @ 2001-10-29 19:00 UTC (permalink / raw)
  To: Linux Kernel

Dear all,

I'm having trouble on SPARC/Linux (of both the 32 and 64 varieties)
getting at the third argument of POSIX sa_sigaction signal handlers.

Consider the following code (a simplified version of what I'm actually
trying to do):
--- Cut here ---
#include <stdlib.h>
#include <sys/ucontext.h>
#include <signal.h>

void sigsegv_handler (int signo, siginfo_t *info, void *data) {
  return;
}

int main () {
  int *foo;
  struct sigaction sa;

  sa.sa_sigaction = sigsegv_handler;
  sa.sa_flags = SA_SIGINFO | SA_RESTART;
  sigaction(SIGSEGV, &sa, NULL);

  foo = NULL;
  *foo = 3;
  return 0;
}
--- Cut here ---
Running under gdb reveals that, whereas on alpha, x86 and ppc the
third argument to sigsegv_handler is a pointer to a ucontext
structure, on sparc and sparc64 I get NULL.

Am I doing something wrong, or is the ucontext argument simply not yet
implemented on the sparc architecture?

Many thanks,

Christophe
-- 
Jesus College, Cambridge, CB5 8BL                           +44 1223 510 299
http://www-jcsu.jesus.cam.ac.uk/~csr21/                  (defun pling-dollar 
(str schar arg) (first (last +))) (make-dispatch-macro-character #\! t)
(set-dispatch-macro-character #\! #\$ #'pling-dollar)

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

* Re: SPARC and SA_SIGINFO signal handling
  2001-10-29 19:00 SPARC and SA_SIGINFO signal handling Christophe Rhodes
@ 2001-10-30 20:51 ` David S. Miller
  2001-10-31  9:43   ` Christophe Rhodes
  2001-10-31 10:11   ` David S. Miller
  0 siblings, 2 replies; 8+ messages in thread
From: David S. Miller @ 2001-10-30 20:51 UTC (permalink / raw)
  To: csr21; +Cc: linux-kernel


You're doing something really wrong, it works perfectly
fine here:

? cat test.c
#include <stdlib.h>
#include <sys/ucontext.h>
#include <signal.h>

void sigsegv_handler (int signo, siginfo_t *info, void *data) {
	if (info != 0)
		exit(1);
	exit(0);
}

int main () {
  int *foo;
  struct sigaction sa;

  sa.sa_sigaction = sigsegv_handler;
  sa.sa_flags = SA_SIGINFO | SA_RESTART;
  sigaction(SIGSEGV, &sa, NULL);

  foo = NULL;
  *foo = 3;
  return 0;
}
? gcc -o test test.c
? ./test
? echo $?
1
? uname -a
Linux pizda.ninka.net 2.4.14-pre4 #1 SMP Mon Oct 29 18:55:18 PST 2001 sparc64 unknown
?

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

* Re: SPARC and SA_SIGINFO signal handling
  2001-10-30 20:51 ` David S. Miller
@ 2001-10-31  9:43   ` Christophe Rhodes
  2001-10-31 10:11   ` David S. Miller
  1 sibling, 0 replies; 8+ messages in thread
From: Christophe Rhodes @ 2001-10-31  9:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-kernel

On Tue, Oct 30, 2001 at 12:51:34PM -0800, David S. Miller wrote:
> 
> You're doing something really wrong, it works perfectly
> fine here:
> 
> ? cat test.c
> #include <stdlib.h>
> #include <sys/ucontext.h>
> #include <signal.h>
> 
> void sigsegv_handler (int signo, siginfo_t *info, void *data) {
> 	if (info != 0)
        ^^^^

This gets me the siginfo struct; this is fine, and I'm happy with this
part.

However, what I don't see to get at is the usercontext/ucontext
structure containing register contents and so on, which as far as I am
aware should be in the third (data) argument to the sa_sigaction-type
sighandler; that's where I'm getting my problems.

> 		exit(1);
> 	exit(0);
> }
> [...]

Change the info above to data, and...

[ x86 does what I expect... ]
csr21@lambda:~$ uname -a
Linux lambda 2.4.13-ac4 #1 Mon Oct 29 18:26:51 GMT 2001 i686 unknown
csr21@lambda:~$ ./foo
csr21@lambda:~$ echo $?
1

[ sparc doesn't ]
csr21@caligula:~$ uname -a
Linux caligula 2.4.6 #1 SMP Sun Sep 30 16:40:07 BST 2001 sparc64
unknown
csr21@caligula:~$ ./foo
csr21@caligula:~$ echo $?
0

Thanks,

Christophe
-- 
Jesus College, Cambridge, CB5 8BL                           +44 1223 510 299
http://www-jcsu.jesus.cam.ac.uk/~csr21/                  (defun pling-dollar 
(str schar arg) (first (last +))) (make-dispatch-macro-character #\! t)
(set-dispatch-macro-character #\! #\$ #'pling-dollar)

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

* Re: SPARC and SA_SIGINFO signal handling
  2001-10-30 20:51 ` David S. Miller
  2001-10-31  9:43   ` Christophe Rhodes
@ 2001-10-31 10:11   ` David S. Miller
  2001-11-03 19:59     ` Richard Henderson
  2001-11-03 23:54     ` David S. Miller
  1 sibling, 2 replies; 8+ messages in thread
From: David S. Miller @ 2001-10-31 10:11 UTC (permalink / raw)
  To: csr21; +Cc: linux-kernel

   From: Christophe Rhodes <csr21@cam.ac.uk>
   Date: Wed, 31 Oct 2001 09:43:43 +0000

   However, what I don't see to get at is the usercontext/ucontext
   structure containing register contents and so on, which as far as I am
   aware should be in the third (data) argument to the sa_sigaction-type
   sighandler; that's where I'm getting my problems.

The "register contents and so on" are in the sigcontext.
We don't use ucontext on sparc32.

Franks a lot,
David S. Miller
davem@redhat.com

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

* Re: SPARC and SA_SIGINFO signal handling
  2001-10-31 10:11   ` David S. Miller
@ 2001-11-03 19:59     ` Richard Henderson
  2001-11-03 23:54     ` David S. Miller
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2001-11-03 19:59 UTC (permalink / raw)
  To: David S. Miller; +Cc: csr21, linux-kernel

On Wed, Oct 31, 2001 at 02:11:31AM -0800, David S. Miller wrote:
> The "register contents and so on" are in the sigcontext.
> We don't use ucontext on sparc32.

In other words, you don't support SA_SIGINFO at all.


r~

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

* Re: SPARC and SA_SIGINFO signal handling
  2001-10-31 10:11   ` David S. Miller
  2001-11-03 19:59     ` Richard Henderson
@ 2001-11-03 23:54     ` David S. Miller
  2001-11-04 17:25       ` Richard Henderson
  2001-11-07  9:33       ` Christophe Rhodes
  1 sibling, 2 replies; 8+ messages in thread
From: David S. Miller @ 2001-11-03 23:54 UTC (permalink / raw)
  To: rth; +Cc: csr21, linux-kernel

   From: Richard Henderson <rth@twiddle.net>
   Date: Sat, 3 Nov 2001 11:59:00 -0800

   On Wed, Oct 31, 2001 at 02:11:31AM -0800, David S. Miller wrote:
   > The "register contents and so on" are in the sigcontext.
   > We don't use ucontext on sparc32.
   
   In other words, you don't support SA_SIGINFO at all.
   
Is it required?  All the information that thing provides is
determinable via other methods.

Franks a lot,
David S. Miller
davem@redhat.com

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

* Re: SPARC and SA_SIGINFO signal handling
  2001-11-03 23:54     ` David S. Miller
@ 2001-11-04 17:25       ` Richard Henderson
  2001-11-07  9:33       ` Christophe Rhodes
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2001-11-04 17:25 UTC (permalink / raw)
  To: David S. Miller; +Cc: csr21, linux-kernel

On Sat, Nov 03, 2001 at 03:54:22PM -0800, David S. Miller wrote:
> Is it required?  All the information that thing provides is
> determinable via other methods.

*shrug* Define "required".  It's a standard format.


r~

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

* Re: SPARC and SA_SIGINFO signal handling
  2001-11-03 23:54     ` David S. Miller
  2001-11-04 17:25       ` Richard Henderson
@ 2001-11-07  9:33       ` Christophe Rhodes
  1 sibling, 0 replies; 8+ messages in thread
From: Christophe Rhodes @ 2001-11-07  9:33 UTC (permalink / raw)
  To: David S. Miller; +Cc: rth, linux-kernel

On Sat, Nov 03, 2001 at 03:54:22PM -0800, David S. Miller wrote:
>    From: Richard Henderson <rth@twiddle.net>
>    Date: Sat, 3 Nov 2001 11:59:00 -0800
> 
>    On Wed, Oct 31, 2001 at 02:11:31AM -0800, David S. Miller wrote:
>    > The "register contents and so on" are in the sigcontext.
>    > We don't use ucontext on sparc32.
>    
>    In other words, you don't support SA_SIGINFO at all.
>    
> Is it required?  All the information that thing provides is
> determinable via other methods.

Sorry for the late response (I've been away); "required" is perhaps
putting it strongly, because as you say the information is there,
somewhere. However, it would be nice to have, as standardized, that
the third argument to the sa_sigaction handler be castable to a
ucontext_t, as this would make porting signal-handling code between
Linux flavours much easier.

Cheers,

Christophe
-- 
Jesus College, Cambridge, CB5 8BL                           +44 1223 510 299
http://www-jcsu.jesus.cam.ac.uk/~csr21/                  (defun pling-dollar 
(str schar arg) (first (last +))) (make-dispatch-macro-character #\! t)
(set-dispatch-macro-character #\! #\$ #'pling-dollar)

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

end of thread, other threads:[~2001-11-07  9:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-29 19:00 SPARC and SA_SIGINFO signal handling Christophe Rhodes
2001-10-30 20:51 ` David S. Miller
2001-10-31  9:43   ` Christophe Rhodes
2001-10-31 10:11   ` David S. Miller
2001-11-03 19:59     ` Richard Henderson
2001-11-03 23:54     ` David S. Miller
2001-11-04 17:25       ` Richard Henderson
2001-11-07  9:33       ` Christophe Rhodes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).