1 # SYNOPSIS
2 #
3 # AX_CHECK_CATCHABLE_SEGV
4 #
5 # DESCRIPTION
6 #
7 # Check whether segmentation violations can be caught using signal handlers.
8
9 #serial 1
10
11 AC_DEFUN([AX_CHECK_CATCHABLE_SEGV], [dnl
12 AC_PREREQ(2.64)
13 AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_check_[]_AC_LANG_ABBREV[]CATCHABLE_SEGV])dnl
14 AC_CACHE_CHECK([whether segmentation violations can be caught when using the _AC_LANG compiler], CACHEVAR, [
15 AC_RUN_IFELSE([
16 AC_LANG_PROGRAM([[
17 #include <signal.h>
18 #include <stdlib.h>
19 static void sig(int _) { exit(0); }
20 ]], [[
21 volatile unsigned char * volatile x = (volatile unsigned char *) malloc(8);
22 size_t i;
23
24 signal(SIGSEGV, sig);
25 signal(SIGBUS, sig);
26 #if !defined(__SANITIZE_ADDRESS__) && !defined(__EMSCRIPTEN__)
27 for (i = 0; i < 10000000; i += 1024) { x[-i] = x[i] = (unsigned char) i; }
28 #endif
29 free((void *) x);
30 exit(1)
31 ]])],
32 [AS_VAR_SET(CACHEVAR, [yes])],
33 [AS_VAR_SET(CACHEVAR, [no])],
34 [AS_VAR_SET(CACHEVAR, [unknown])]
35 )
36 ])
37 AS_VAR_IF(CACHEVAR, yes,
38 [AC_DEFINE([HAVE_CATCHABLE_SEGV], [1], [Define if segmentation violations can be caught using signal handlers])],
39 [AC_MSG_WARN([On this platform, segmentation violations cannot be caught using signal handlers. This is expected if you enabled a tool such as Address Sanitizer (-fsanitize=address), but be aware that using Address Sanitizer may also significantly reduce performance.])]
40 )
41 AS_VAR_POPDEF([CACHEVAR])dnl
42 ])
Cache object: 39ce4e1fdcdad1070227f7432012b3f1
|