[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libsigsegv 2.5: bug in OpenBSD4.0

From: Bruno Haible
Subject: Re: libsigsegv 2.5: bug in OpenBSD4.0
Date: Mon, 21 Jul 2008 02:29:45 +0200
User-agent: KMail/1.5.4

Hi Eric,

> Also, I think many of the stackvma-*.c files have async-safety bugs, which 
> render them less than perfect for use in stack overflow detection.  For 
> example, stackvma-procfs.c has a comment about why sigsegv_get_vma uses malloc
> () instead of alloca(), but in the case of a stack overflow occurring during 
> a 
> previous malloc, you might cause deadlock by recursively invoking non-async-
> safe malloc.  Likewise for stackvma-linux.c calling fscanf.

Good observation. I never noticed this problem because when clisp gets a
SIGSEGV it is very rarely inside a malloc() or similar call.

It is now fixed: libsigsegv now usss open() instead of fopen(), and
mmap() instead of malloc(). (stackvma-procfs.c is only used on Solaris, OSF/1,
IRIX, which all have mmap().)

Many thanks for the remark!

2008-07-20  Bruno Haible  <address@hidden>

        Make sigsegv_get_vma async-safe.
        * src/sigsegv.h.in (sigsegv_handler_t, stackoverflow_handler_t):
        Mention async-safety constraints.
        + src/stackvma-rofile.c: New file.
        * src/stackvma-freebsd.c: Include stackvma-rofile.c.
        (sigsegv_get_vma): Use struct rofile instead of FILE.
        * src/stackvma-linux.c: Include stackvma-rofile.c.
        (sigsegv_get_vma): Use struct rofile instead of FILE.
        * src/stackvma-procfs.c: Include <sys/mman.h> instead of <stdlib.h> and
        (sigsegv_get_vma): Avoid using sprintf. Ensure pagesize is initialized.
        Use mmap/munmap instead of malloc/free.
        * src/Makefile.am (EXTRA_DIST): Add stackvma-rofile.c.
        Reported by Eric Blake <address@hidden>.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]