From 33eaf4c27e32ae163e1d36e7b4d8df28c2acb4f2 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Wed, 16 Dec 2015 16:31:02 -0500 Subject: [PATCH] mem-cleanup, cont'd. Remove LEVITTE_DEBUG_MEM. Remove {OPENSSL,CRYPTO}_remalloc. Reviewed-by: Viktor Dukhovni --- crypto/mem.c | 22 ------------------- crypto/mem_dbg.c | 46 +--------------------------------------- include/openssl/crypto.h | 3 --- util/libeay.num | 2 +- 4 files changed, 2 insertions(+), 71 deletions(-) diff --git a/crypto/mem.c b/crypto/mem.c index 83a1547dc9..a1a75a2ddc 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -291,9 +291,6 @@ void *CRYPTO_malloc(int num, const char *file, int line) malloc_debug_func(NULL, num, file, line, 0); } ret = malloc_ex_func(num, file, line); -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num); -#endif if (malloc_debug_func != NULL) malloc_debug_func(ret, num, file, line, 1); @@ -334,10 +331,6 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line) if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret = realloc_ex_func(str, num, file, line); -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, - ret, num); -#endif if (realloc_debug_func != NULL) realloc_debug_func(str, ret, num, file, line, 1); @@ -369,11 +362,6 @@ void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file, memcpy(ret, str, old_len); OPENSSL_clear_free(str, old_len); } -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, - "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", - str, ret, num); -#endif if (realloc_debug_func != NULL) realloc_debug_func(str, ret, num, file, line, 1); @@ -384,9 +372,6 @@ void CRYPTO_free(void *str) { if (free_debug_func != NULL) free_debug_func(str, 0); -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str); -#endif free_func(str); if (free_debug_func != NULL) free_debug_func(NULL, 1); @@ -401,13 +386,6 @@ void CRYPTO_clear_free(void *str, size_t num) CRYPTO_free(str); } -void *CRYPTO_remalloc(void *a, int num, const char *file, int line) -{ - OPENSSL_free(a); - a = OPENSSL_malloc(num); - return (a); -} - void CRYPTO_set_mem_debug_options(long bits) { if (set_debug_options_func != NULL) diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 9a48410bea..292bf2aef7 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -373,15 +373,6 @@ static APP_INFO *pop_info(void) next->references++; (void)lh_APP_INFO_insert(amih, next); } -#ifdef LEVITTE_DEBUG_MEM - if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid)) { - fprintf(stderr, - "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n", - CRYPTO_THREADID_hash(&ret->threadid), - CRYPTO_THREADID_hash(&tmp.threadid)); - abort(); - } -#endif if (--(ret->references) <= 0) { ret->next = NULL; if (next != NULL) @@ -420,18 +411,8 @@ int CRYPTO_push_info_(const char *info, const char *file, int line) ami->references = 1; ami->next = NULL; - if ((amim = lh_APP_INFO_insert(amih, ami)) != NULL) { -#ifdef LEVITTE_DEBUG_MEM - if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid)) { - fprintf(stderr, - "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n", - CRYPTO_THREADID_hash(&amim->threadid), - CRYPTO_THREADID_hash(&ami->threadid)); - abort(); - } -#endif + if ((amim = lh_APP_INFO_insert(amih, ami)) != NULL) ami->next = amim; - } err: MemCheck_on(); /* release MALLOC2 lock */ } @@ -514,10 +495,6 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, m->order = order; } m->order = order++; -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] %c 0x%p (%d)\n", - m->order, (before_p & 128) ? '*' : '+', m->addr, m->num); -#endif if (options & V_CRYPTO_MDEBUG_TIME) m->time = time(NULL); else @@ -565,10 +542,6 @@ void CRYPTO_dbg_free(void *addr, int before_p) m.addr = addr; mp = lh_MEM_delete(mh, &m); if (mp != NULL) { -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n", - mp->order, mp->addr, mp->num); -#endif app_info_free(mp->app_info); OPENSSL_free(mp); } @@ -587,12 +560,6 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, { MEM m, *mp; -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, - "LEVITTE_DEBUG_MEM: --> CRYPTO_dbg_malloc(addr1 = %p, addr2 = %p, num = %d, file = \"%s\", line = %d, before_p = %d)\n", - addr1, addr2, num, file, line, before_p); -#endif - switch (before_p) { case 0: break; @@ -611,11 +578,6 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, m.addr = addr1; mp = lh_MEM_delete(mh, &m); if (mp != NULL) { -#ifdef LEVITTE_DEBUG_MEM - fprintf(stderr, - "LEVITTE_DEBUG_MEM: [%5ld] * 0x%p (%d) -> 0x%p (%d)\n", - mp->order, mp->addr, mp->num, addr2, num); -#endif mp->addr = addr2; mp->num = num; #if defined(CRYPTO_MDEBUG_BACKTRACE) && defined(__GNUC__) @@ -716,12 +678,6 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l) while (amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti)); } -#ifdef LEVITTE_DEBUG_MEM - if (amip) { - fprintf(stderr, "Thread switch detected in backtrace!!!!\n"); - abort(); - } -#endif #if defined(CRYPTO_MDEBUG_BACKTRACE) && defined(__GNUC__) { size_t i; diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index 977481b57d..e0cea6a991 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -328,8 +328,6 @@ int CRYPTO_is_mem_check_on(void); CRYPTO_realloc((char *)addr, (int)num, __FILE__, __LINE__) # define OPENSSL_realloc_clean(addr,old_num,num) \ CRYPTO_realloc_clean(addr, old_num, num, __FILE__, __LINE__) -# define OPENSSL_remalloc(addr,num) \ - CRYPTO_remalloc((char **)addr, (int)num, __FILE__, __LINE__) # define OPENSSL_clear_free(addr, num) CRYPTO_clear_free(addr, num) # define OPENSSL_free(addr) CRYPTO_free(addr) @@ -484,7 +482,6 @@ void CRYPTO_clear_free(void *ptr, size_t num); void *CRYPTO_realloc(void *addr, int num, const char *file, int line); void *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file, int line); -void *CRYPTO_remalloc(void *addr, int num, const char *file, int line); # define OPENSSL_secure_malloc(num) \ CRYPTO_secure_malloc((int)num,__FILE__,__LINE__) diff --git a/util/libeay.num b/util/libeay.num index 2b5a6221e3..e9a678bc43 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -183,7 +183,7 @@ CRYPTO_mem_leaks 190 1_1_0 EXIST::FUNCTION: CRYPTO_mem_leaks_cb 191 1_1_0 EXIST::FUNCTION: CRYPTO_mem_leaks_fp 192 1_1_0 EXIST::FUNCTION:STDIO CRYPTO_realloc 193 1_1_0 EXIST::FUNCTION: -CRYPTO_remalloc 194 1_1_0 EXIST::FUNCTION: +CRYPTO_remalloc 194 1_1_0 NOEXIST::FUNCTION: CRYPTO_set_add_lock_callback 195 1_1_0 EXIST::FUNCTION: CRYPTO_set_id_callback 196 1_1_0 EXIST::FUNCTION:DEPRECATED CRYPTO_set_locking_callback 197 1_1_0 EXIST::FUNCTION: -- GitLab