|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| build-aux/ | H | 16-Jan-2018 | - | 15,680 | 11,779 |
| m4/ | H | 16-Jan-2018 | - | 10,080 | 9,164 |
| src/ | H | 16-Jan-2018 | - | 8,269 | 4,588 |
| tests/ | H | 16-Jan-2018 | - | 2,465 | 1,795 |
| AUTHORS | H A D | 02-Jan-2014 | 242 | 6 | 4 |
| COPYING | H A D | 02-Jan-2014 | 17.7 KiB | 341 | 282 |
| ChangeLog | H A D | 16-Jan-2018 | 53.3 KiB | 1,590 | 1,179 |
| ChangeLog.1 | H A D | 02-Jan-2014 | 12.1 KiB | 296 | 224 |
| INSTALL | H A D | 02-Jan-2014 | 9.5 KiB | 235 | 178 |
| Makefile.am | H A D | 09-Oct-2017 | 2.9 KiB | 78 | 39 |
| Makefile.in | H A D | 16-Jan-2018 | 27.8 KiB | 887 | 779 |
| Makefile.msvc | H A D | 02-Jan-2014 | 3.3 KiB | 124 | 77 |
| NEWS | H A D | 16-Jan-2018 | 4.7 KiB | 150 | 111 |
| PORTING | H A D | 12-Nov-2017 | 23.8 KiB | 363 | 346 |
| README | H A D | 16-Jan-2018 | 6 KiB | 160 | 116 |
| README.windows | H A D | 23-Nov-2016 | 10.1 KiB | 256 | 208 |
| aclocal.m4 | H A D | 16-Jan-2018 | 42.6 KiB | 1,197 | 1,087 |
| config.h.in | H A D | 16-Jan-2018 | 4.5 KiB | 157 | 107 |
| config.h.msvc | H A D | 16-Jan-2018 | 4.5 KiB | 157 | 107 |
| configure | H A D | 16-Jan-2018 | 543.9 KiB | 19,215 | 16,160 |
| configure.ac | H A D | 16-Jan-2018 | 31.4 KiB | 1,032 | 936 |
README
1 GNU libsigsegv - Handling page faults in user mode
2
3This is a library for handling page faults in user mode. A page fault
4occurs when a program tries to access to a region of memory that is
5currently not available. Catching and handling a page fault is a useful
6technique for implementing:
7
8 - pageable virtual memory,
9 - memory-mapped access to persistent databases,
10 - generational garbage collectors,
11 - stack overflow handlers,
12 - distributed shared memory,
13 - ...
14
15This library supports three sets of functions, all defined in <sigsegv.h>:
16
17 - Global SIGSEGV handlers:
18 sigsegv_install_handler, sigsegv_deinstall_handler.
19
20 - Local SIGSEGV handlers (a handler per memory area):
21 sigsegv_init, sigsegv_register, sigsegv_unregister, sigsegv_dispatch.
22
23 - Stack overflow handlers:
24 stackoverflow_install_handler, stackoverflow_deinstall_handler.
25
26Each of the three APIs can be used independently or simultaneously.
27For examples of the use of the APIs, see:
28
29 - Global SIGSEGV handlers: see tests/sigsegv1.c.
30 - Local SIGSEGV handlers: see tests/sigsegv2.c.
31 - Stack overflow handlers: see tests/stackoverflow1.c.
32
33
34About portability.
35
36Some platforms don't support this functionality. In <sigsegv.h>, the
37preprocessor macro HAVE_SIGSEGV_RECOVERY will be defined if global and
38local SIGSEGV handlers are available, and the preprocessor macro
39HAVE_STACK_OVERFLOW_RECOVERY will be defined if stack overflow handlers
40are available. Note that the declared functions are available in all cases;
41on platforms where HAVE_SIGSEGV_RECOVERY or HAVE_STACK_OVERFLOW_RECOVERY is
42not defined, they will simply always return an error code or do nothing.
43
44The list of platforms where this library is known to work is contained in
45the file PORTING.
46
47
48About pageable virtual memory.
49
50Pageable virtual memory is usually done in the operating system's kernel.
51This library helps in implementing the others.
52
53Installing a page fault handler is usually more efficient than doing
54access checks in software at every access, because it's effectively the
55hardware (the MMU) which checks whether a page is present or not.
56
57Note that if you use system calls (like read()) to write into write-
58protected pages, the system will react by returning -1 and setting
59errno to EFAULT, instead of signalling SIGSEGV and restarting the system
60call. In this case, the program has to do what the SIGSEGV handler would
61do, and then restart the read() operation. Some buggy systems (SunOS 4)
62go into an endless loop on this occasion; on these systems you have to
63make sure that an area is writable _before_ you call read() on it,
64
65
66About stack overflow handlers.
67
68In some applications, the stack overflow handler performs some cleanup or
69notifies the user and then immediately terminates the application. In
70other applications, the stack overflow handler longjmps back to a central
71point in the application. This library supports both uses. In the second
72case, the handler must ensure to restore the normal signal mask (because
73many signals are blocked while the handler is executed), and must also
74call sigsegv_leave_handler() to transfer control; then only it can longjmp
75away.
76
77Note that longjmping back to a central point in the application can leave
78the application in an inconsistent state, because
79 1) no cleanup is executed for call frames that are being unwound,
80 2) the code being executed while the stack overflow occurred might leave
81 data structures in an intermediate, inconsistent state.
82If you want to avoid the first problem, you need to restructure your
83application into three or more threads:
84 - a main thread, which creates the other threads,
85 - worker threads, which may cause stack overflows, and in which all
86 cleanups are registered through the pthread_cleanup_push function,
87 - a handler thread, which contains the handler for stack overflow and
88 other kinds of SIGSEGV. The handler will call pthread_cancel on the
89 worker thread whose stack overflowed.
90You will need to use the function pthread_sigmask on all threads except
91the handler thread, in order to ensure that the SIGSEGV signal gets handled
92in the designated handler thread.
93If you want to avoid the second problem together with the first problem,
94you need to enclose code that manipulates data structures in a way that is
95not safe to be interrupted within calls to pthread_setcancelstate() or
96pthread_setcanceltype().
97If you want to avoid just the second problem, you need to manipulate all data
98structures in a way that is safe to be interrupted at any moment and also
99compile your program with the gcc flag -fnon-call-exceptions.
100
101
102About shared libraries.
103
104This library builds as a static library by default. This seems useful
105because of the small size of the library (4 KB). Of course, you can build
106it as a shared library by specifying the configure option '--enable-shared'.
107
108
109Installation
110------------
111
112Installation instructions on Unix:
113
114 ./configure [OPTIONS]
115 make
116 make check
117 make install
118
119Installation instructions on Microsoft Windows:
120
121 See README.windows.
122
123
124Using libsigsegv in your package:
125 - For the APIs, see the comments in the <sigsegv.h> file (generated from
126 src/sigsegv.h.in).
127 - An autoconf macro for determining where libsigsegv is installed and how to
128 link with it is part of GNU gnulib, see
129 <https://www.gnu.org/software/gnulib/MODULES.html#module=libsigsegv>
130
131
132Copyright notice
133----------------
134
135Copyright 1998-1999, 2002-2012, 2016-2018 Bruno Haible <bruno@clisp.org>
136Copyright 2002-2005, 2009 Paolo Bonzini <bonzini@gnu.org>
137Copyright 2008-2010 Eric Blake <ebb9@byu.net>
138
139This is free software distributed under the GNU General Public Licence v2
140described in the file COPYING or (at your option) any later version.
141There is ABSOLUTELY NO WARRANTY, explicit or implied, on this software.
142
143
144Download
145--------
146
147 https://ftp.gnu.org/gnu/libsigsegv/libsigsegv-2.12.tar.gz
148
149Homepage
150--------
151
152 https://www.gnu.org/software/libsigsegv/
153 https://savannah.gnu.org/projects/libsigsegv
154 http://libsigsegv.sourceforge.net/ (old)
155
156Bug reports to
157--------------
158
159 <bug-libsigsegv@gnu.org>
160
README.windows
1Installation on Microsoft Windows:
2
3There are three ways to create binaries of this package for Microsoft Windows:
41) Native binaries, built using the mingw tool chain.
52) Native binaries, built using the MS Visual C/C++ tool chain.
63) Binaries for the Cygwin environment.
7
8===============================================================================
91) Native binaries, built using the mingw tool chain.
10
11 I recommend to use the Cygwin environment as the development environment
12 and mingw only as the target (runtime, deployment) environment.
13 For this, you need to install
14 * Cygwin (from https://cygwin.com/),
15 * some packages available from the Cygwin package installer:
16 make
17 * the mingw cross-compilation tools and runtime package, available from
18 the Cygwin package installer (setup-x86_64.exe):
19 - for creating 32-bit binaries: packages
20 mingw64-i686-gcc-core,
21 mingw64-i686-headers,
22 mingw64-i686-runtime
23 - for creating 64-bit binaries: packages
24 mingw64-x86_64-gcc-core,
25 mingw64-x86_64-headers,
26 mingw64-x86_64-runtime
27
28 Building 32-bit binaries for mingw is achieved through the following
29 preparation, configure, and build commands:
30
31 PATH=/usr/local/mingw32/bin:$PATH
32 export PATH
33 ./configure --host=i686-w64-mingw32 --prefix=/usr/local/mingw32 \
34 CC=i686-w64-mingw32-gcc \
35 CPPFLAGS="-I/usr/local/mingw32/include -Wall" \
36 LDFLAGS="-L/usr/local/mingw32/lib"
37 make
38 make check
39
40 Building 64-bit binaries for mingw is achieved through the following
41 preparation, configure, and build commands:
42
43 PATH=/usr/local/mingw64/bin:$PATH
44 export PATH
45 ./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/mingw64 \
46 CC=x86_64-w64-mingw32-gcc \
47 CPPFLAGS="-I/usr/local/mingw64/include -Wall" \
48 LDFLAGS="-L/usr/local/mingw64/lib"
49 make
50 make check
51
52 Installation:
53
54 make install
55
56===============================================================================
572) Native binaries, built using the MS Visual C/C++ tool chain.
58
59 Note that binaries created with MSVC have a distribution constraint: They
60 depend on a closed-source library ('msvcr90.dll' for MSVC 9.0,
61 'vcruntime140.dll' for MSVC 14.0, and so on) which is not normally part of
62 a Windows installation.
63 You cannot distribute 'vcruntime*.dll' with the binaries - this would be a
64 violation of the GPL and of the Microsoft EULA.
65 You can distribute the binaries without including 'vcruntime*.dll'. Users
66 who don't have this library on their system will require to pull some files
67 (api-ms-win*.dll) through the Windows Update mechanism, see
68 https://support.microsoft.com/en-us/kb/2999226 .
69
70 This recipe requires MS Visual C/C++ 9.0 or newer.
71 You don't need the Visual Studio IDE, just the C/C++ tool chain.
72 As of 2016, you can install the MS Visual C/C++ 14.0 tool chain from
73 http://landinghub.visualstudio.com/visual-cpp-build-tools (it's the file
74 visualcppbuildtools_full.exe).
75
76 This recipe requires also a Cygwin environment (with 'bash', the common POSIX
77 commands, and 'make') as a build environment. Building with 'nmake' is not
78 supported.
79 For this, you need to install
80 * Cygwin (from https://cygwin.com/),
81 * some packages available from the Cygwin package installer:
82 make
83
84 You also need the scripts 'ar-lib' and 'compile' from
85 http://git.savannah.gnu.org/gitweb/?p=automake.git;a=blob_plain;f=lib/ar-lib;hb=HEAD
86 http://git.savannah.gnu.org/gitweb/?p=automake.git;a=blob_plain;f=lib/compile;hb=HEAD
87 respectively.
88 They may also be included in this package, in directory 'build-aux/'.
89 Save them; the instructions below assume that you stored them in $HOME/msvc/.
90 Make them executable:
91 chmod a+x ar-lib compile
92
93 Start a bash (from Cygwin).
94
95 Make sure that the MSVC tools ("cl" etc.) are found in PATH and the
96 environment variables INCLUDE and LIB are set appropriately.
97 In a typical MSVC 9.0 installation, it can be achieved by running
98 C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat
99 In a typical MSVC 14.0 installation on Windows 10, it can be achieved
100 - for creating 32-bit binaries: through the following bash commands:
101
102 # Set environment variables for using MSVC 14,
103 # for creating native 32-bit Windows executables.
104
105 # Windows C library headers and libraries.
106 WindowsCrtIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt'
107 WindowsCrtLibDir='C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\'
108 INCLUDE="${WindowsCrtIncludeDir};$INCLUDE"
109 LIB="${WindowsCrtLibDir}x86;$LIB"
110
111 # Windows API headers and libraries.
112 WindowsSdkIncludeDir='C:\Program Files (x86)\Windows Kits\8.1\Include\'
113 WindowsSdkLibDir='C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\'
114 INCLUDE="${WindowsSdkIncludeDir}um;${WindowsSdkIncludeDir}shared;$INCLUDE"
115 LIB="${WindowsSdkLibDir}x86;$LIB"
116
117 # Visual C++ tools, headers and libraries.
118 VSINSTALLDIR='C:\Program Files (x86)\Microsoft Visual Studio 14.0'
119 VCINSTALLDIR="${VSINSTALLDIR}"'\VC'
120 PATH=`cygpath -u "${VCINSTALLDIR}"`/bin:"$PATH"
121 INCLUDE="${VCINSTALLDIR}"'\include;'"${INCLUDE}"
122 LIB="${VCINSTALLDIR}"'\lib;'"${LIB}"
123
124 export INCLUDE LIB
125
126 - for creating 64-bit binaries: through the following bash commands:
127
128 # Set environment variables for using MSVC 14,
129 # for creating native 64-bit Windows executables.
130
131 # Windows C library headers and libraries.
132 WindowsCrtIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt'
133 WindowsCrtLibDir='C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\'
134 INCLUDE="${WindowsCrtIncludeDir};$INCLUDE"
135 LIB="${WindowsCrtLibDir}x64;$LIB"
136
137 # Windows API headers and libraries.
138 WindowsSdkIncludeDir='C:\Program Files (x86)\Windows Kits\8.1\Include\'
139 WindowsSdkLibDir='C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\'
140 INCLUDE="${WindowsSdkIncludeDir}um;${WindowsSdkIncludeDir}shared;$INCLUDE"
141 LIB="${WindowsSdkLibDir}x64;$LIB"
142
143 # Visual C++ tools, headers and libraries.
144 VSINSTALLDIR='C:\Program Files (x86)\Microsoft Visual Studio 14.0'
145 VCINSTALLDIR="${VSINSTALLDIR}"'\VC'
146 PATH=`cygpath -u "${VCINSTALLDIR}"`/bin/amd64:"$PATH"
147 INCLUDE="${VCINSTALLDIR}"'\include;'"${INCLUDE}"
148 LIB="${VCINSTALLDIR}"'\lib\amd64;'"${LIB}"
149
150 export INCLUDE LIB
151
152 Building 32-bit binaries with MSVC is achieved through the following
153 preparation, configure, and build commands:
154
155 PATH=/usr/local/msvc32/bin:$PATH
156 export PATH
157
158 win32_target=_WIN32_WINNT_WINXP # for MSVC 9.0
159 win32_target=_WIN32_WINNT_VISTA # possibly for MSVC >= 10.0
160 win32_target=_WIN32_WINNT_WIN7 # possibly for MSVC >= 10.0
161 win32_target=_WIN32_WINNT_WIN8 # possibly for MSVC >= 10.0
162
163 ./configure --host=i686-w64-mingw32 --prefix=/usr/local/msvc32 \
164 CC="$HOME/msvc/compile cl -nologo" \
165 CFLAGS="-MD" \
166 CXX="$HOME/msvc/compile cl -nologo" \
167 CXXFLAGS="-MD" \
168 CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc32/include" \
169 LDFLAGS="-L/usr/local/msvc32/lib" \
170 LD="link" \
171 NM="dumpbin -symbols" \
172 STRIP=":" \
173 AR="$HOME/msvc/ar-lib lib" \
174 RANLIB=":"
175 make
176 make check
177
178 Building 64-bit binaries with MSVC is achieved through the following
179 preparation, configure, and build commands:
180
181 PATH=/usr/local/msvc64/bin:$PATH
182 export PATH
183
184 win32_target=_WIN32_WINNT_WINXP # for MSVC 9.0
185 win32_target=_WIN32_WINNT_VISTA # possibly for MSVC >= 10.0
186 win32_target=_WIN32_WINNT_WIN7 # possibly for MSVC >= 10.0
187 win32_target=_WIN32_WINNT_WIN8 # possibly for MSVC >= 10.0
188
189 ./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/msvc64 \
190 CC="$HOME/msvc/compile cl -nologo" \
191 CFLAGS="-MD" \
192 CXX="$HOME/msvc/compile cl -nologo" \
193 CXXFLAGS="-MD" \
194 CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc64/include" \
195 LDFLAGS="-L/usr/local/msvc64/lib" \
196 LD="link" \
197 NM="dumpbin -symbols" \
198 STRIP=":" \
199 AR="$HOME/msvc/ar-lib lib" \
200 RANLIB=":"
201 make
202 make check
203
204 Installation:
205
206 make install
207
208===============================================================================
2093) Binaries for the Cygwin environment.
210
211 The generic instructions in the INSTALL file apply. But here are more
212 specific ones.
213
214 You need to install
215 * Cygwin (from https://cygwin.com/),
216 * some packages available from the Cygwin package installer:
217 make
218 * the Cygwin [cross-]compilation tools package, available from
219 the Cygwin package installer (setup-x86_64.exe):
220 - for creating 32-bit binaries: packages
221 cygwin32-gcc-core,
222 cygwin32
223 - for creating 64-bit binaries: packages
224 gcc-core
225
226 Building 32-bit binaries for Cygwin must be done in a directory *outside*
227 the Cygwin /home and /usr hierarchies. It is achieved through the following
228 preparation, configure, and build commands:
229
230 PATH=/usr/local/cygwin32/bin:/usr/i686-pc-cygwin/sys-root/usr/bin:$PATH
231 export PATH
232 ./configure --host=i686-pc-cygwin --prefix=/usr/local/cygwin32 \
233 CC=i686-pc-cygwin-gcc \
234 CPPFLAGS="-I/usr/local/cygwin32/include -Wall" \
235 LDFLAGS="-L/usr/local/cygwin32/lib"
236 make
237 make check
238
239 Building 64-bit binaries for Cygwin is achieved through the following
240 preparation, configure, and build commands:
241
242 PATH=/usr/local/cygwin64/bin:$PATH
243 export PATH
244 ./configure --host=x86_64-pc-cygwin --prefix=/usr/local/cygwin64 \
245 CC=x86_64-pc-cygwin-gcc \
246 CPPFLAGS="-I/usr/local/cygwin64/include -Wall" \
247 LDFLAGS="-L/usr/local/cygwin64/lib"
248 make
249 make check
250
251 Installation:
252
253 make install
254
255===============================================================================
256