SPARC and SA_SIGINFO signal handling
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
Signature · 4 lines
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)
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 ?
Quoted 11 lines · David S. Miller
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.
Quoted 4 lines
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
Signature · 4 lines
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)
From: Christophe Rhodes <[email protected]>
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
[email protected]
Quoted 2 lines · David S. Miller
Is it required? All the information that thing provides is determinable via other methods.
*shrug* Define "required". It's a standard format.
r~
Quoted 11 lines · David S. Miller
From: Richard Henderson <[email protected]>
Date: Sat, 3 Nov 2001 11:59:00 -0800Quoted 2 lines · David S. Miller
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_SIGINFOat 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
Signature · 4 lines
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)
Quoted 2 lines · David S. Miller
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~
From: Richard Henderson <[email protected]>
Date: Sat, 3 Nov 2001 11:59:00 -0800
Quoted 2 lines · David S. Miller
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
[email protected]