You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2020/10/13 18:59:39 UTC
[qpid-dispatch] branch master updated: DISPATCH-1795: avoid
backtrace dumps for suppressed pool leaks
This is an automated email from the ASF dual-hosted git repository.
kgiusti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new 11e71c9 DISPATCH-1795: avoid backtrace dumps for suppressed pool leaks
11e71c9 is described below
commit 11e71c962651477a9ab66598f296fe04381d43b9
Author: Kenneth Giusti <kg...@apache.org>
AuthorDate: Tue Oct 13 11:36:11 2020 -0400
DISPATCH-1795: avoid backtrace dumps for suppressed pool leaks
This closes #876
---
src/alloc_pool.c | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/src/alloc_pool.c b/src/alloc_pool.c
index 6277a96..194422b 100644
--- a/src/alloc_pool.c
+++ b/src/alloc_pool.c
@@ -77,7 +77,7 @@ DEQ_DECLARE(qd_alloc_type_t, qd_alloc_type_list_t);
// Be a Good Citizen when adding unexpected leaks to this list and include the
// corresponding JIRA in a comment!
//
-#ifdef QD_MEMORY_DEBUG
+#if QD_MEMORY_STATS
static const char *leaking_types[] = {
// DISPATCH-1679:
"qd_timer_t", "qd_connector_t",
@@ -591,10 +591,19 @@ void qd_alloc_finalize(void)
//
#if QD_MEMORY_STATS
if (dump_file && desc->stats->total_free_to_heap < desc->stats->total_alloc_from_heap) {
+ bool suppressed = false;
+ for (int i = 0; leaking_types[i]; ++i) {
+ if (strcmp(desc->type_name, leaking_types[i]) == 0) {
+ suppressed = true;
+ break;
+ }
+ }
fprintf(dump_file,
- "alloc.c: Items of type '%s' remain allocated at shutdown: %"PRId64"\n",
+ "alloc.c: Items of type '%s' remain allocated at shutdown: %"PRId64"%s\n",
desc->type_name,
- desc->stats->total_alloc_from_heap - desc->stats->total_free_to_heap);
+ desc->stats->total_alloc_from_heap - desc->stats->total_free_to_heap,
+ suppressed ? " (SUPPRESSED)" : "");
+
#ifdef QD_MEMORY_DEBUG
qd_alloc_type_t *qtype = (qd_alloc_type_t*) desc->debug;
qd_alloc_item_t *item = DEQ_HEAD(qtype->allocated);
@@ -603,25 +612,18 @@ void qd_alloc_finalize(void)
DEQ_REMOVE_HEAD(qtype->allocated);
char **strings = backtrace_symbols(item->backtrace, item->backtrace_size);
- // is this leak suppressed?
- bool suppress = false;
- for (int i = 0; leaking_types[i]; ++i) {
- if (strcmp(desc->type_name, leaking_types[i]) == 0) {
- suppress = true;
- break;
- }
- }
- if (!suppress)
+ if (!suppressed) {
+ // DISPATCH-1795: avoid output noise by only printing
+ // backtraces for leaks that are not suppressed
+ qd_log_formatted_time(&item->timestamp, buf, 100);
+ fprintf(dump_file, "Leak: %s type: %s address: %p\n",
+ buf, desc->type_name, (void *)(&item[1]));
+ for (size_t i = 0; i < item->backtrace_size; i++)
+ fprintf(dump_file, "%s\n", strings[i]);
+ fprintf(dump_file, "\n");
last_leak = desc->type_name;
-
- qd_log_formatted_time(&item->timestamp, buf, 100);
- fprintf(dump_file, "Leak: %s type: %s address: %p%s\n",
- buf, desc->type_name, (void *)(&item[1]),
- (suppress) ? " (suppressed)" : "");
- for (size_t i = 0; i < item->backtrace_size; i++)
- fprintf(dump_file, "%s\n", strings[i]);
+ }
free(strings);
- fprintf(dump_file, "\n");
// free the item to prevent ASAN from also reporting this leak.
// Since this is a custom heap ASAN will dump the first
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org