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 <[EMAIL PROTECTED]>
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
<stdio.h>.
(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 <[EMAIL PROTECTED]>.