1 GNU libsigsegv - Handling page faults in user mode
3 This is a library for handling page faults in user mode. A page fault
4 occurs when a program tries to access to a region of memory that is
5 currently not available. Catching and handling a page fault is a useful
6 technique for implementing:
8 - pageable virtual memory,
9 - memory-mapped access to persistent databases,
10 - generational garbage collectors,
11 - stack overflow handlers,
12 - distributed shared memory,
15 This library supports three sets of functions, all defined in <sigsegv.h>:
17 - Global SIGSEGV handlers:
18 sigsegv_install_handler, sigsegv_deinstall_handler.
20 - Local SIGSEGV handlers (a handler per memory area):
21 sigsegv_init, sigsegv_register, sigsegv_unregister, sigsegv_dispatch.
23 - Stack overflow handlers:
24 stackoverflow_install_handler, stackoverflow_deinstall_handler.
26 Each of the three APIs can be used independently or simultaneously.
27 For examples of the use of the APIs, see:
29 - Global SIGSEGV handlers: see tests/sigsegv1.c.
30 - Local SIGSEGV handlers: see tests/sigsegv2.c.
31 - Stack overflow handlers: see tests/stackoverflow1.c.
36 Some platforms don't support this functionality. In <sigsegv.h>, the
37 preprocessor macro HAVE_SIGSEGV_RECOVERY will be defined if global and
38 local SIGSEGV handlers are available, and the preprocessor macro
39 HAVE_STACK_OVERFLOW_RECOVERY will be defined if stack overflow handlers
40 are available. Note that the declared functions are available in all cases;
41 on platforms where HAVE_SIGSEGV_RECOVERY or HAVE_STACK_OVERFLOW_RECOVERY is
42 not defined, they will simply always return an error code or do nothing.
44 The list of platforms where this library is known to work is contained in
48 About pageable virtual memory.
50 Pageable virtual memory is usually done in the operating system's kernel.
51 This library helps in implementing the others.
53 Installing a page fault handler is usually more efficient than doing
54 access checks in software at every access, because it's effectively the
55 hardware (the MMU) which checks whether a page is present or not.
57 Note that if you use system calls (like read()) to write into write-
58 protected pages, the system will react by returning -1 and setting
59 errno to EFAULT, instead of signalling SIGSEGV and restarting the system
60 call. In this case, the program has to do what the SIGSEGV handler would
61 do, and then restart the read() operation. Some buggy systems (SunOS 4)
62 go into an endless loop on this occasion; on these systems you have to
63 make sure that an area is writable _before_ you call read() on it,
66 About stack overflow handlers.
68 In some applications, the stack overflow handler performs some cleanup or
69 notifies the user and then immediately terminates the application. In
70 other applications, the stack overflow handler longjmps back to a central
71 point in the application. This library supports both uses. In the second
72 case, the handler must ensure to restore the normal signal mask (because
73 many signals are blocked while the handler is executed), and must also
74 call sigsegv_leave_handler(); then only it can longjmp away.
77 About shared libraries.
79 This library builds as a static library by default. This seems useful
80 because of the small size of the library (4 KB). Of course, you can build
81 it as a shared library by specifying the configure option '--enable-shared'.
84 Installation instructions on Unix:
91 Installation instructions on Woe32:
97 Copyright 1998-1999, 2002-2007 Bruno Haible <bruno@clisp.org>
98 Copyright 2002-2007 Paolo Bonzini <bonzini@gnu.org>
100 This is free software distributed under the GNU General Public Licence
101 described in the file COPYING. There is ABSOLUTELY NO WARRANTY, explicit or
102 implied, on this software.
107 ftp://ftp.gnu.org/pub/gnu/libsigsegv/libsigsegv-2.7.tar.gz
108 http://ftp.gnu.org/gnu/libsigsegv/libsigsegv-2.7.tar.gz
112 http://libsigsegv.sourceforge.net/