Bug 31922 - SIGTERM cause segfault
Summary: SIGTERM cause segfault
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Raw Hide
Classification: Retired
Component: gcc
Version: 1.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-03-16 01:12 UTC by Olivier Baudron
Modified: 2007-04-18 16:32 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-03-16 15:24:17 UTC
Embargoed:


Attachments (Terms of Use)

Description Olivier Baudron 2001-03-16 01:12:31 UTC
The following bug happens when compiling with kcc-1.1.2-40
(and not with gcc-2.96-78).

test.c:
--------------------------- cut here ---------------------------------
#include <stdio.h>
#include <signal.h>

void arret (int n) {
    int err=0;

    printf ("err=%d\n", err);
}

int main (int argc, char **argv) {
    int err[4];
    struct sigaction sig;

    sig.sa_handler = arret;
    err[0] = sigaction (SIGTERM, &sig, NULL);

    while (1);

    return 0;
}
--------------------------- cut here ---------------------------------

$ kgcc -Wall -g -o test test.c
$ ./test

Then, send SIGTERM to the process 'test'.
This one halts with: Segmentation fault

Note: The kernel is a 2.2.4, and glibc is 2.2.2-5.

Comment 1 Jakub Jelinek 2001-03-16 11:08:13 UTC
Cannot reproduce it with either glibc 2.2.2-4 and 2.2.2-6, (there were no
suspicious changes in 2.2.2-5), on kernel 2.4.0.

Comment 2 Olivier Baudron 2001-03-16 13:04:59 UTC
If this can help, feel free to test the "bug" on my PC:
$ ssh -l guest baud.dyndns.org
The password is 'guest'.
Files 'test.c' and 'test' are in the homedir.

Comment 3 Jakub Jelinek 2001-03-16 13:29:36 UTC
The issue is that you don't have compat-glibc installed. kgcc does not require
it, since kgcc is for kernel compilation only. If you want to use it for
userland compilation, then you should install compat-egcs (and that requires
compat-glibc) and use either egcs or i386-glibc21-linux-gcc gcc drivers.
BTW: This has been revamped recently, so there is no kgcc package any longer
and egcs/kgcc/egcs++ commands in compat-* packages mean egcs 1.1.2 using
glibc 2.2.2 headers and linking against those libraries, while i386-glibc21-*
commands use glibc 2.1.x headers and link against 2.1.x libraries.

Comment 4 Olivier Baudron 2001-03-16 15:24:06 UTC
In fact the testcase is very sensitive to lots of things. For example, a
different order in the declaration of variables makes it works or not. This
makes me think that something is wrong somewhere in gcc or glibc...

I found a new testcase that segfaults (on a SIGTERM signal) with gcc-2.96-78 +
glibc-2.2.2-5 + kernel-2.4.2. Would you mind testing it at RedHat or on my PC?

test.c:
--------------------------- cut here ---------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>

void arret (int n) {
    printf ("End.\n");
    exit (0);
}

int main (int argc, char **argv) {
    struct sigaction sig;
    int err;

    sig.sa_handler = arret;
    err = sigaction (SIGTERM, &sig, NULL);

    while (1);

    return 0;
}
--------------------------- cut here ---------------------------------

Comment 5 Olivier Baudron 2001-03-16 15:42:22 UTC
Sorry, the bug was in the programmer (me)!


Note You need to log in before you can comment on or make changes to this bug.