diff options
| author | Stefan Kangas | 2024-01-03 05:11:10 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2024-01-03 05:11:10 +0100 |
| commit | 5a1cd1bb98f74710d3b2a227755c5627a256dafb (patch) | |
| tree | 2cb470c1497dbd71a438bf1755865e6415448008 /src/alloc.c | |
| parent | 91bc775b0c60342f118640001d2ce293d4f1f7ef (diff) | |
| download | emacs-5a1cd1bb98f74710d3b2a227755c5627a256dafb.tar.gz emacs-5a1cd1bb98f74710d3b2a227755c5627a256dafb.zip | |
Delete obsolete GC debugging code
This code was introduced in 2014 to catch a GC bug that, according to
Paul Eggert in 2019, "seems to have been fixed" (see 2b552f34892
2019-08-21 "Don’t debug fset by default"). It has been marked
obsolete since that time, and no one has mentioned it on our mailing
lists since. Let's just get rid of it.
* src/alloc.c
(SUSPICIOUS_OBJECT_CHECKING) [ENABLE_CHECKING]: Don't define.
(suspicious_free_record, suspicious_objects, suspicious_object_index)
(suspicious_free_history, suspicious_free_history_index)
(note_suspicious_free) [SUSPICIOUS_OBJECT_CHECKING]: Delete.
(find_suspicious_object_in_range)
(detect_suspicious_free): Delete functions.
(cleanup_vector)
(allocate_vectorlike): Don't call above deleted functions.
(Fsuspicious_object): Delete DEFUN.
(syms_of_alloc) <Ssuspicious_object>: Delete defsubr.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/src/alloc.c b/src/alloc.c index 3e29c61f1ff..53ba85d88b7 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -412,31 +412,6 @@ static EMACS_INT gc_threshold; | |||
| 412 | 412 | ||
| 413 | const char *pending_malloc_warning; | 413 | const char *pending_malloc_warning; |
| 414 | 414 | ||
| 415 | /* Pointer sanity only on request. FIXME: Code depending on | ||
| 416 | SUSPICIOUS_OBJECT_CHECKING is obsolete; remove it entirely. */ | ||
| 417 | #ifdef ENABLE_CHECKING | ||
| 418 | #define SUSPICIOUS_OBJECT_CHECKING 1 | ||
| 419 | #endif | ||
| 420 | |||
| 421 | #ifdef SUSPICIOUS_OBJECT_CHECKING | ||
| 422 | struct suspicious_free_record | ||
| 423 | { | ||
| 424 | void *suspicious_object; | ||
| 425 | void *backtrace[128]; | ||
| 426 | }; | ||
| 427 | static void *suspicious_objects[32]; | ||
| 428 | static int suspicious_object_index; | ||
| 429 | struct suspicious_free_record suspicious_free_history[64] EXTERNALLY_VISIBLE; | ||
| 430 | static int suspicious_free_history_index; | ||
| 431 | /* Find the first currently-monitored suspicious pointer in range | ||
| 432 | [begin,end) or NULL if no such pointer exists. */ | ||
| 433 | static void *find_suspicious_object_in_range (void *begin, void *end); | ||
| 434 | static void detect_suspicious_free (void *ptr); | ||
| 435 | #else | ||
| 436 | # define find_suspicious_object_in_range(begin, end) ((void *) NULL) | ||
| 437 | # define detect_suspicious_free(ptr) ((void) 0) | ||
| 438 | #endif | ||
| 439 | |||
| 440 | /* Maximum amount of C stack to save when a GC happens. */ | 415 | /* Maximum amount of C stack to save when a GC happens. */ |
| 441 | 416 | ||
| 442 | #ifndef MAX_SAVE_STACK | 417 | #ifndef MAX_SAVE_STACK |
| @@ -3351,7 +3326,6 @@ vectorlike_nbytes (const union vectorlike_header *hdr) | |||
| 3351 | static void | 3326 | static void |
| 3352 | cleanup_vector (struct Lisp_Vector *vector) | 3327 | cleanup_vector (struct Lisp_Vector *vector) |
| 3353 | { | 3328 | { |
| 3354 | detect_suspicious_free (vector); | ||
| 3355 | if ((vector->header.size & PSEUDOVECTOR_FLAG) == 0) | 3329 | if ((vector->header.size & PSEUDOVECTOR_FLAG) == 0) |
| 3356 | return; /* nothing more to do for plain vectors */ | 3330 | return; /* nothing more to do for plain vectors */ |
| 3357 | switch (PSEUDOVECTOR_TYPE (vector)) | 3331 | switch (PSEUDOVECTOR_TYPE (vector)) |
| @@ -3629,9 +3603,6 @@ allocate_vectorlike (ptrdiff_t len, bool clearit) | |||
| 3629 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); | 3603 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
| 3630 | #endif | 3604 | #endif |
| 3631 | 3605 | ||
| 3632 | if (find_suspicious_object_in_range (p, (char *) p + nbytes)) | ||
| 3633 | emacs_abort (); | ||
| 3634 | |||
| 3635 | tally_consing (nbytes); | 3606 | tally_consing (nbytes); |
| 3636 | vector_cells_consed += len; | 3607 | vector_cells_consed += len; |
| 3637 | 3608 | ||
| @@ -8019,78 +7990,6 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) | |||
| 8019 | return unbind_to (gc_count, found); | 7990 | return unbind_to (gc_count, found); |
| 8020 | } | 7991 | } |
| 8021 | 7992 | ||
| 8022 | #ifdef SUSPICIOUS_OBJECT_CHECKING | ||
| 8023 | |||
| 8024 | static void * | ||
| 8025 | find_suspicious_object_in_range (void *begin, void *end) | ||
| 8026 | { | ||
| 8027 | char *begin_a = begin; | ||
| 8028 | char *end_a = end; | ||
| 8029 | int i; | ||
| 8030 | |||
| 8031 | for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) | ||
| 8032 | { | ||
| 8033 | char *suspicious_object = suspicious_objects[i]; | ||
| 8034 | if (begin_a <= suspicious_object && suspicious_object < end_a) | ||
| 8035 | return suspicious_object; | ||
| 8036 | } | ||
| 8037 | |||
| 8038 | return NULL; | ||
| 8039 | } | ||
| 8040 | |||
| 8041 | static void | ||
| 8042 | note_suspicious_free (void *ptr) | ||
| 8043 | { | ||
| 8044 | struct suspicious_free_record *rec; | ||
| 8045 | |||
| 8046 | rec = &suspicious_free_history[suspicious_free_history_index++]; | ||
| 8047 | if (suspicious_free_history_index == | ||
| 8048 | ARRAYELTS (suspicious_free_history)) | ||
| 8049 | { | ||
| 8050 | suspicious_free_history_index = 0; | ||
| 8051 | } | ||
| 8052 | |||
| 8053 | memset (rec, 0, sizeof (*rec)); | ||
| 8054 | rec->suspicious_object = ptr; | ||
| 8055 | backtrace (&rec->backtrace[0], ARRAYELTS (rec->backtrace)); | ||
| 8056 | } | ||
| 8057 | |||
| 8058 | static void | ||
| 8059 | detect_suspicious_free (void *ptr) | ||
| 8060 | { | ||
| 8061 | int i; | ||
| 8062 | |||
| 8063 | eassert (ptr != NULL); | ||
| 8064 | |||
| 8065 | for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) | ||
| 8066 | if (suspicious_objects[i] == ptr) | ||
| 8067 | { | ||
| 8068 | note_suspicious_free (ptr); | ||
| 8069 | suspicious_objects[i] = NULL; | ||
| 8070 | } | ||
| 8071 | } | ||
| 8072 | |||
| 8073 | #endif /* SUSPICIOUS_OBJECT_CHECKING */ | ||
| 8074 | |||
| 8075 | DEFUN ("suspicious-object", Fsuspicious_object, Ssuspicious_object, 1, 1, 0, | ||
| 8076 | doc: /* Return OBJ, maybe marking it for extra scrutiny. | ||
| 8077 | If Emacs is compiled with suspicious object checking, capture | ||
| 8078 | a stack trace when OBJ is freed in order to help track down | ||
| 8079 | garbage collection bugs. Otherwise, do nothing and return OBJ. */) | ||
| 8080 | (Lisp_Object obj) | ||
| 8081 | { | ||
| 8082 | #ifdef SUSPICIOUS_OBJECT_CHECKING | ||
| 8083 | /* Right now, we care only about vectors. */ | ||
| 8084 | if (VECTORLIKEP (obj)) | ||
| 8085 | { | ||
| 8086 | suspicious_objects[suspicious_object_index++] = XVECTOR (obj); | ||
| 8087 | if (suspicious_object_index == ARRAYELTS (suspicious_objects)) | ||
| 8088 | suspicious_object_index = 0; | ||
| 8089 | } | ||
| 8090 | #endif | ||
| 8091 | return obj; | ||
| 8092 | } | ||
| 8093 | |||
| 8094 | #ifdef ENABLE_CHECKING | 7993 | #ifdef ENABLE_CHECKING |
| 8095 | 7994 | ||
| 8096 | bool suppress_checking; | 7995 | bool suppress_checking; |
| @@ -8322,7 +8221,6 @@ N should be nonnegative. */); | |||
| 8322 | #ifdef HAVE_MALLOC_TRIM | 8221 | #ifdef HAVE_MALLOC_TRIM |
| 8323 | defsubr (&Smalloc_trim); | 8222 | defsubr (&Smalloc_trim); |
| 8324 | #endif | 8223 | #endif |
| 8325 | defsubr (&Ssuspicious_object); | ||
| 8326 | 8224 | ||
| 8327 | Lisp_Object watcher; | 8225 | Lisp_Object watcher; |
| 8328 | 8226 | ||