glibc 2.0.7 POSIX signals, I/O blocking & egcs 1.1b
Frederick A Niles (Rick)
niles@axp745.gsfc.nasa.gov
Wed Nov 11 15:21:00 GMT 1998
I understand this may be completely a glibc problem, but
could you please look at it. I can gladly send along the
assembly for a "good" version and a "bad" version. But I
sort of assume this has been seen before.
(details see below)
Thanks,
Rick Niles.
/**
* Runtime Segmentation fault.
* This is a bug involving the POSIX signal system calls and a
* character buffer. System: Linux 2.1.127/glibc 2.0.7/egcs 1.1b.
* Attempt to reproduce the fault by running this and then hitting C-c
* to cause a SIGINT to happen. It seems to be a compiler issue since
* the existance of 'buf' is required for the fault to happen.
*
* Rick Niles <niles@axp745.gsfc.nasa.gov>
**/
#define _POSIX_SOURCE 1
#include <stdio.h>
#include <signal.h>
void callback(/*@unused@*/ int i) { }
/* Main */
int
main(int argc, char *argv[])
{
/**
* If this declaration of this character buffer is moved or
* removed the bug goes away. Also, size 8 is okay, but 9 is not.
**/
char buf[9];
/* The bug only happen with POSIX style signals */
#ifdef _POSIX_SOURCE
struct sigaction act, oact;
act.sa_handler = callback;
(void) sigemptyset(&(act.sa_mask));
(void) sigaction(SIGINT, &act, &oact);
#else
signal(SIGINT, callback); /* <-- This version will not fault */
#endif
/* Insert any blocking system call here. */
/* Then hit C-c to trigger a SIGINT */
{
char c = getchar();
}
return 0;
}
More information about the Gcc-bugs
mailing list