1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Audit mem contexts returned from functions into the calling context.

It is possible for functions to accidentally leak child contexts into the calling context, which may use a lot of memory depending on the use case and where it happens.

Use the function return type to determine what should be returned and error when something else is returned. Add FUNCTION_AUDIT_*() macros to handle exceptions.

This checking is only performed during unit tests on the code being covered by the specific unit test.

Note that this does not work yet for memory allocations, i.e. memNew(). These are pretty rare so are not as much of an issue and they can be added in the future.
This commit is contained in:
David Steele
2023-01-12 17:36:57 +07:00
parent de1dfb66ca
commit 9ca492cecf
79 changed files with 603 additions and 70 deletions
+8 -8
View File
@@ -79,13 +79,6 @@ unit:
- common/debug
- common/type/stringStatic
# ----------------------------------------------------------------------------------------------------------------------------
- name: type-convert
total: 12
coverage:
- common/type/convert
# ----------------------------------------------------------------------------------------------------------------------------
- name: assert-off
total: 1
@@ -109,7 +102,7 @@ unit:
# ----------------------------------------------------------------------------------------------------------------------------
- name: mem-context
total: 7
total: 8
feature: memContext
coverage:
@@ -118,6 +111,13 @@ unit:
depend:
- common/type/convert
# ----------------------------------------------------------------------------------------------------------------------------
- name: type-convert
total: 12
coverage:
- common/type/convert
# ----------------------------------------------------------------------------------------------------------------------------
- name: time
total: 3