diff options
| author | Paul Eggert | 2014-11-29 23:30:22 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-11-29 23:32:29 -0800 |
| commit | 3517da701ea5d16c296745d6678988b06bee615d (patch) | |
| tree | aa890d2a3915c69ce9a6a41714bc8cad9c6c3b70 /src/alloc.c | |
| parent | 70723e5107fd92c31e5b395d58be0b20b13c322d (diff) | |
| download | emacs-3517da701ea5d16c296745d6678988b06bee615d.tar.gz emacs-3517da701ea5d16c296745d6678988b06bee615d.zip | |
Port better to AddressSanitizer.
These changes suffice for temacs on x86-64 with GCC 4.9.2 and
-fsanitize=address.
* alloc.c (valid_pointer_p) [ADDRESS_SANITIZER]:
Return -1 or 0, as the pipe trick doesn't work.
* alloc.c (relocatable_string_data_p, mark_object, sweep_symbols):
* data.c (Ffset):
* print.c (print_object):
When a pointer-check primitive returns -1, do not assume this
means the pointer is valid or that the underlying system has failed.
It could just be that addresses are being sanitized so Emacs can't
test for pointer validity.
* lisp.h (defined_GC_CHECK_STRING_BYTES): New constant.
(USE_STACK_STRING) [GC_CHECK_STRING_BYTES]: Now false, since the
string validity checker doesn't work on stack-based strings.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/alloc.c b/src/alloc.c index faad0b59c87..1019c2af6cc 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -4934,6 +4934,10 @@ valid_pointer_p (void *p) | |||
| 4934 | #ifdef WINDOWSNT | 4934 | #ifdef WINDOWSNT |
| 4935 | return w32_valid_pointer_p (p, 16); | 4935 | return w32_valid_pointer_p (p, 16); |
| 4936 | #else | 4936 | #else |
| 4937 | |||
| 4938 | if (ADDRESS_SANITIZER) | ||
| 4939 | return p ? -1 : 0; | ||
| 4940 | |||
| 4937 | int fd[2]; | 4941 | int fd[2]; |
| 4938 | 4942 | ||
| 4939 | /* Obviously, we cannot just access it (we would SEGV trying), so we | 4943 | /* Obviously, we cannot just access it (we would SEGV trying), so we |
| @@ -4949,7 +4953,7 @@ valid_pointer_p (void *p) | |||
| 4949 | return valid; | 4953 | return valid; |
| 4950 | } | 4954 | } |
| 4951 | 4955 | ||
| 4952 | return -1; | 4956 | return -1; |
| 4953 | #endif | 4957 | #endif |
| 4954 | } | 4958 | } |
| 4955 | 4959 | ||
| @@ -5048,8 +5052,8 @@ relocatable_string_data_p (const char *str) | |||
| 5048 | struct sdata *sdata | 5052 | struct sdata *sdata |
| 5049 | = (struct sdata *) (str - offsetof (struct sdata, data)); | 5053 | = (struct sdata *) (str - offsetof (struct sdata, data)); |
| 5050 | 5054 | ||
| 5051 | if (valid_pointer_p (sdata) | 5055 | if (0 < valid_pointer_p (sdata) |
| 5052 | && valid_pointer_p (sdata->string) | 5056 | && 0 < valid_pointer_p (sdata->string) |
| 5053 | && maybe_lisp_pointer (sdata->string)) | 5057 | && maybe_lisp_pointer (sdata->string)) |
| 5054 | return (valid_lisp_object_p | 5058 | return (valid_lisp_object_p |
| 5055 | (make_lisp_ptr (sdata->string, Lisp_String)) | 5059 | (make_lisp_ptr (sdata->string, Lisp_String)) |
| @@ -6364,7 +6368,7 @@ mark_object (Lisp_Object arg) | |||
| 6364 | CHECK_ALLOCATED_AND_LIVE (live_symbol_p); | 6368 | CHECK_ALLOCATED_AND_LIVE (live_symbol_p); |
| 6365 | ptr->gcmarkbit = 1; | 6369 | ptr->gcmarkbit = 1; |
| 6366 | /* Attempt to catch bogus objects. */ | 6370 | /* Attempt to catch bogus objects. */ |
| 6367 | eassert (valid_lisp_object_p (ptr->function) >= 1); | 6371 | eassert (valid_lisp_object_p (ptr->function)); |
| 6368 | mark_object (ptr->function); | 6372 | mark_object (ptr->function); |
| 6369 | mark_object (ptr->plist); | 6373 | mark_object (ptr->plist); |
| 6370 | switch (ptr->redirect) | 6374 | switch (ptr->redirect) |
| @@ -6749,7 +6753,7 @@ sweep_symbols (void) | |||
| 6749 | ++num_used; | 6753 | ++num_used; |
| 6750 | sym->s.gcmarkbit = 0; | 6754 | sym->s.gcmarkbit = 0; |
| 6751 | /* Attempt to catch bogus objects. */ | 6755 | /* Attempt to catch bogus objects. */ |
| 6752 | eassert (valid_lisp_object_p (sym->s.function) >= 1); | 6756 | eassert (valid_lisp_object_p (sym->s.function)); |
| 6753 | } | 6757 | } |
| 6754 | } | 6758 | } |
| 6755 | 6759 | ||