All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: Paul Maurides <stud1313@di.uoa.gr>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>
Subject: Re: 2.6.x signal handler bug
Date: Mon, 28 Jun 2004 23:56:01 +0200	[thread overview]
Message-ID: <20040628215601.GD29901@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <40DCBBC3.2010308@di.uoa.gr>

On Sat, 26 June 2004 02:56:51 +0300, Paul Maurides wrote:
> 
> The bug has been reproduced successfully using the following program
> on kernel 2.6.5 and 2.6.7, and probably affects any other 2.6 kernel.

All, since about 2.5.71 or so.

> Kernel 2.4 produce the correct behavior, an endless loop of handled 
> signals, but on kernel 2.6 the program segfaults.

The program never returns from it's signal handler.  Instead, it
causes yet another segfault.  Any program stupid enough to cause a
segfault inside the segfault handler, should be killed.  Full stop.

> #include <signal.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <setjmp.h>
> 
> volatile int len;
> volatile int real;
> volatile int caught;
> jmp_buf env;
> 
> void catcher(int sig){
>    signal(SIGSEGV,catcher);
>    printf("requested: %9d malloced: %9d\n",len,real);
>    longjmp(env, 1);
> }
> 
> int main(){
>    char* p=0;
>    len = 0;
>    signal(SIGSEGV,catcher);
> 
>    setjmp(env);
>    len++;
>    free(p);
>    p = malloc(len);
>    real = 0;
>    while(1){
>        p[real] = 0;
>        real++;
>    }
>    return 0;
> }

Jörn

-- 
Fancy algorithms are buggier than simple ones, and they're much harder
to implement. Use simple algorithms as well as simple data structures.
-- Rob Pike

  parent reply	other threads:[~2004-06-28 21:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-25 23:56 2.6.x signal handler bug Paul Maurides
2004-06-26  0:07 ` Andrew Morton
2004-06-26  1:33 ` David Wagner
2004-06-28 21:56 ` Jörn Engel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-06-26 14:33 Steve G
2004-06-26 16:05 ` Davide Libenzi
2004-06-27 22:16   ` Andries Brouwer
2004-06-27 22:45     ` Davide Libenzi
2004-06-27 22:51       ` Davide Libenzi
2004-06-28  2:01         ` Steve G
2004-06-28 11:26         ` Steve G
2004-06-28 14:56           ` Davide Libenzi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040628215601.GD29901@wohnheim.fh-wedel.de \
    --to=joern@wohnheim.fh-wedel.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stud1313@di.uoa.gr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.