diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-26 23:00:55 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-26 23:00:55 +0300 |
| commit | 3f194f1c7264945a63b0018b159cc83bd9385c59 (patch) | |
| tree | 4d277264e75b197844eae154e96e73d9cd54de3a /tests/create-exhaustion | |
| parent | 1b5a553194f47066d60bb1c9475af1f413af8f4a (diff) | |
| download | kmi-3f194f1c7264945a63b0018b159cc83bd9385c59.tar.gz kmi-3f194f1c7264945a63b0018b159cc83bd9385c59.zip | |
fix memory leaks destroying threads
Diffstat (limited to 'tests/create-exhaustion')
| -rw-r--r-- | tests/create-exhaustion/init.c | 29 | ||||
| -rw-r--r-- | tests/create-exhaustion/source.mk | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/create-exhaustion/init.c b/tests/create-exhaustion/init.c new file mode 100644 index 0000000..d5ac20a --- /dev/null +++ b/tests/create-exhaustion/init.c @@ -0,0 +1,29 @@ +#include <common/test.h> + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(pid); + UNUSED(tid); + UNUSED(d0); + UNUSED(d1); + UNUSED(d2); + UNUSED(d3); + + size_t old_ram = 0; + while (1) { + printf("creating new thread\n"); + id_t new_thread = sys_create((uintptr_t)_start, 1, 2, 3, 4); + if (new_thread < 0) + break; + + old_ram = sys_conf_get(CONF_RAM_USAGE, 0); + } + + /* this might not be guaranteed due to how we're currently mapping the + * rpc stack, but good enough for now */ + size_t ram = sys_conf_get(CONF_RAM_USAGE, 0); + check(ram == old_ram, "'leaked' memory building thread without enough memory\n"); + + /* no crash is good enough */ + ok(); +} diff --git a/tests/create-exhaustion/source.mk b/tests/create-exhaustion/source.mk new file mode 100644 index 0000000..d096746 --- /dev/null +++ b/tests/create-exhaustion/source.mk @@ -0,0 +1,2 @@ +DO != ./scripts/gen-prog -n create-exhaustion -p init init.c +DO != ./scripts/gen-simple -n create-exhaustion -p init |
