mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
Remove mallinfo() from codebase
Now deprecated in libc >= 2.33 Closes #40309 Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
21317c9229
commit
296a557bfc
3
changes/ticket40309
Normal file
3
changes/ticket40309
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
o New system requirements (mallinfo() deprecated):
|
||||||
|
- Remove mallinfo() usage entirely. Libc 2.33+ now deprecates it. Closes
|
||||||
|
ticket 40309.
|
@ -1937,7 +1937,6 @@ AS_CASE([$malloc],
|
|||||||
|
|
||||||
[system], [
|
[system], [
|
||||||
# handle this later, including the jemalloc fallback
|
# handle this later, including the jemalloc fallback
|
||||||
AC_CHECK_FUNCS(mallinfo)
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
|
[AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
|
||||||
|
@ -316,7 +316,6 @@ dumpmemusage(int severity)
|
|||||||
dump_routerlist_mem_usage(severity);
|
dump_routerlist_mem_usage(severity);
|
||||||
dump_cell_pool_usage(severity);
|
dump_cell_pool_usage(severity);
|
||||||
dump_dns_mem_usage(severity);
|
dump_dns_mem_usage(severity);
|
||||||
tor_log_mallinfo(severity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write all statistics to the log, with log level <b>severity</b>. Called
|
/** Write all statistics to the log, with log level <b>severity</b>. Called
|
||||||
|
@ -37,29 +37,6 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISABLE_GCC_WARNING(aggregate-return)
|
|
||||||
/** Call the platform malloc info function, and dump the results to the log at
|
|
||||||
* level <b>severity</b>. If no such function exists, do nothing. */
|
|
||||||
void
|
|
||||||
tor_log_mallinfo(int severity)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_MALLINFO
|
|
||||||
struct mallinfo mi;
|
|
||||||
memset(&mi, 0, sizeof(mi));
|
|
||||||
mi = mallinfo();
|
|
||||||
tor_log(severity, LD_MM,
|
|
||||||
"mallinfo() said: arena=%d, ordblks=%d, smblks=%d, hblks=%d, "
|
|
||||||
"hblkhd=%d, usmblks=%d, fsmblks=%d, uordblks=%d, fordblks=%d, "
|
|
||||||
"keepcost=%d",
|
|
||||||
mi.arena, mi.ordblks, mi.smblks, mi.hblks,
|
|
||||||
mi.hblkhd, mi.usmblks, mi.fsmblks, mi.uordblks, mi.fordblks,
|
|
||||||
mi.keepcost);
|
|
||||||
#else /* !(defined(HAVE_MALLINFO)) */
|
|
||||||
(void)severity;
|
|
||||||
#endif /* defined(HAVE_MALLINFO) */
|
|
||||||
}
|
|
||||||
ENABLE_GCC_WARNING(aggregate-return)
|
|
||||||
|
|
||||||
#if defined(HW_PHYSMEM64)
|
#if defined(HW_PHYSMEM64)
|
||||||
/* OpenBSD and NetBSD define this */
|
/* OpenBSD and NetBSD define this */
|
||||||
#define INT64_HW_MEM HW_PHYSMEM64
|
#define INT64_HW_MEM HW_PHYSMEM64
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include "lib/testsupport/testsupport.h"
|
#include "lib/testsupport/testsupport.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
void tor_log_mallinfo(int severity);
|
|
||||||
MOCK_DECL(int, get_total_system_memory, (size_t *mem_out));
|
MOCK_DECL(int, get_total_system_memory, (size_t *mem_out));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6394,57 +6394,6 @@ test_util_get_unquoted_path(void *arg)
|
|||||||
tor_free(r);
|
tor_free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
test_util_log_mallinfo(void *arg)
|
|
||||||
{
|
|
||||||
(void)arg;
|
|
||||||
char *log1 = NULL, *log2 = NULL, *mem = NULL;
|
|
||||||
#ifdef HAVE_MALLINFO
|
|
||||||
setup_capture_of_logs(LOG_INFO);
|
|
||||||
tor_log_mallinfo(LOG_INFO);
|
|
||||||
expect_single_log_msg_containing("mallinfo() said: ");
|
|
||||||
mock_saved_log_entry_t *lg = smartlist_get(mock_saved_logs(), 0);
|
|
||||||
log1 = tor_strdup(lg->generated_msg);
|
|
||||||
|
|
||||||
mock_clean_saved_logs();
|
|
||||||
mem = tor_malloc(8192);
|
|
||||||
tor_log_mallinfo(LOG_INFO);
|
|
||||||
expect_single_log_msg_containing("mallinfo() said: ");
|
|
||||||
lg = smartlist_get(mock_saved_logs(), 0);
|
|
||||||
log2 = tor_strdup(lg->generated_msg);
|
|
||||||
|
|
||||||
/* Make sure that the amount of used memory increased. */
|
|
||||||
const char *used1 = strstr(log1, "uordblks=");
|
|
||||||
const char *used2 = strstr(log2, "uordblks=");
|
|
||||||
tt_assert(used1);
|
|
||||||
tt_assert(used2);
|
|
||||||
used1 += strlen("uordblks=");
|
|
||||||
used2 += strlen("uordblks=");
|
|
||||||
|
|
||||||
int ok1, ok2;
|
|
||||||
char *next1 = NULL, *next2 = NULL;
|
|
||||||
uint64_t mem1 = tor_parse_uint64(used1, 10, 0, UINT64_MAX, &ok1, &next1);
|
|
||||||
uint64_t mem2 = tor_parse_uint64(used2, 10, 0, UINT64_MAX, &ok2, &next2);
|
|
||||||
tt_assert(ok1);
|
|
||||||
tt_assert(ok2);
|
|
||||||
tt_assert(next1);
|
|
||||||
tt_assert(next2);
|
|
||||||
if (mem2 == 0) {
|
|
||||||
/* This is a fake mallinfo that doesn't actually fill in its outputs. */
|
|
||||||
tt_u64_op(mem1, OP_EQ, 0);
|
|
||||||
} else {
|
|
||||||
tt_u64_op(mem1, OP_LT, mem2);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
tt_skip();
|
|
||||||
#endif
|
|
||||||
done:
|
|
||||||
teardown_capture_of_logs();
|
|
||||||
tor_free(log1);
|
|
||||||
tor_free(log2);
|
|
||||||
tor_free(mem);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define UTIL_LEGACY(name) \
|
#define UTIL_LEGACY(name) \
|
||||||
{ #name, test_util_ ## name , 0, NULL, NULL }
|
{ #name, test_util_ ## name , 0, NULL, NULL }
|
||||||
|
|
||||||
@ -6584,6 +6533,5 @@ struct testcase_t util_tests[] = {
|
|||||||
UTIL_TEST(monotonic_time_add_msec, 0),
|
UTIL_TEST(monotonic_time_add_msec, 0),
|
||||||
UTIL_TEST(htonll, 0),
|
UTIL_TEST(htonll, 0),
|
||||||
UTIL_TEST(get_unquoted_path, 0),
|
UTIL_TEST(get_unquoted_path, 0),
|
||||||
UTIL_TEST(log_mallinfo, 0),
|
|
||||||
END_OF_TESTCASES
|
END_OF_TESTCASES
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user