diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2022-10-13 08:04:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 08:04:14 +0300 |
commit | 2974f525ec703329ef6ad079d8f6c685cfab11ad (patch) | |
tree | b0e289a5fee787d764ee37cb8b5c2ac7bcd1bd20 /database | |
parent | c805a9afad71ac96e703d599cbd6f54c29142ca7 (diff) |
overload libc memory allocators with custom ones to trace all allocations (#13810)
* overload libc memory allocators with custom ones to trace all allocations
* grab libc pointers for external c plugins
* use -ldl when necessary; fallback to work without dlsym when it is not available
* initialize global variable
* add optional dl libs
* dynamically link every library function when needed for the first time
* prevent crashes on musl libc
* another attempt
* dont dereference function
* attempt no 3
* attempt no 4
* cleanup - all attempts failed
* dont enable tracing of allocations
* missing parenthesis
Diffstat (limited to 'database')
-rw-r--r-- | database/engine/datafile.c | 4 | ||||
-rw-r--r-- | database/engine/journalfile.c | 8 | ||||
-rw-r--r-- | database/engine/metadata_log/logfile.c | 2 | ||||
-rw-r--r-- | database/engine/rrdengine.c | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/database/engine/datafile.c b/database/engine/datafile.c index fa158e69db..9c70068d9f 100644 --- a/database/engine/datafile.c +++ b/database/engine/datafile.c @@ -174,7 +174,7 @@ int create_data_file(struct rrdengine_datafile *datafile) rrd_stat_atomic_add(&global_io_errors, 1); } uv_fs_req_cleanup(&req); - free(superblock); + posix_memfree(superblock); if (ret < 0) { destroy_data_file(datafile); return ret; @@ -218,7 +218,7 @@ static int check_data_file_superblock(uv_file file) ret = 0; } error: - free(superblock); + posix_memfree(superblock); return ret; } diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c index 95c3a46f80..a79084bc92 100644 --- a/database/engine/journalfile.c +++ b/database/engine/journalfile.c @@ -17,7 +17,7 @@ static void flush_transaction_buffer_cb(uv_fs_t* req) } uv_fs_req_cleanup(req); - free(io_descr->buf); + posix_memfree(io_descr->buf); freez(io_descr); } @@ -225,7 +225,7 @@ int create_journal_file(struct rrdengine_journalfile *journalfile, struct rrdeng rrd_stat_atomic_add(&global_io_errors, 1); } uv_fs_req_cleanup(&req); - free(superblock); + posix_memfree(superblock); if (ret < 0) { destroy_journal_file(journalfile, datafile); return ret; @@ -268,7 +268,7 @@ static int check_journal_file_superblock(uv_file file) ret = 0; } error: - free(superblock); + posix_memfree(superblock); return ret; } @@ -483,7 +483,7 @@ static uint64_t iterate_transactions(struct rrdengine_instance *ctx, struct rrde } skip_file: if (unlikely(!journal_is_mmapped)) - free(buf); + posix_memfree(buf); return max_id; } diff --git a/database/engine/metadata_log/logfile.c b/database/engine/metadata_log/logfile.c index fa5961b307..e8063e934e 100644 --- a/database/engine/metadata_log/logfile.c +++ b/database/engine/metadata_log/logfile.c @@ -103,7 +103,7 @@ static int check_metadata_logfile_superblock(uv_file file) error("File has unknown version %"PRIu16". Compatibility is not guaranteed.", superblock->version); } error: - free(superblock); + posix_memfree(superblock); return ret; } diff --git a/database/engine/rrdengine.c b/database/engine/rrdengine.c index ce808aadbc..61c57edbf1 100644 --- a/database/engine/rrdengine.c +++ b/database/engine/rrdengine.c @@ -422,7 +422,7 @@ after_crc_check: if (xt_io_descr->completion) completion_mark_complete(xt_io_descr->completion); uv_fs_req_cleanup(req); - free(xt_io_descr->buf); + posix_memfree(xt_io_descr->buf); freez(xt_io_descr); } @@ -696,7 +696,7 @@ void flush_pages_cb(uv_fs_t* req) if (xt_io_descr->completion) completion_mark_complete(xt_io_descr->completion); uv_fs_req_cleanup(req); - free(xt_io_descr->buf); + posix_memfree(xt_io_descr->buf); freez(xt_io_descr); uv_rwlock_wrlock(&pg_cache->committed_page_index.lock); |