2019-04-30 22:54:58 +02:00
|
|
|
#include <pthread.h>
|
2020-06-17 22:39:50 +02:00
|
|
|
#include <stdio.h>
|
2024-10-04 00:30:52 +02:00
|
|
|
#include <stdlib.h>
|
2019-04-30 22:54:58 +02:00
|
|
|
|
2022-02-07 11:54:57 +01:00
|
|
|
#if defined(__GLIBC__) || defined(__ANDROID__)
|
2019-04-30 22:54:58 +02:00
|
|
|
#include <malloc.h>
|
2022-02-07 11:54:57 +01:00
|
|
|
#endif
|
2019-04-30 22:54:58 +02:00
|
|
|
|
2020-06-17 22:39:50 +02:00
|
|
|
#include "test_util.h"
|
2022-01-04 17:56:48 +01:00
|
|
|
#include "../util.h"
|
2020-06-17 22:39:50 +02:00
|
|
|
|
|
|
|
OPTNONE static void leak_memory(void) {
|
2021-12-26 15:34:37 +01:00
|
|
|
(void)!malloc(1024 * 1024 * 1024);
|
|
|
|
(void)!malloc(16);
|
|
|
|
(void)!malloc(32);
|
|
|
|
(void)!malloc(4096);
|
2019-04-30 22:54:58 +02:00
|
|
|
}
|
|
|
|
|
2022-01-04 17:56:48 +01:00
|
|
|
static void *do_work(UNUSED void *p) {
|
2019-04-30 22:54:58 +02:00
|
|
|
leak_memory();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
pthread_t thread[4];
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
pthread_create(&thread[i], NULL, do_work, NULL);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
pthread_join(thread[i], NULL);
|
|
|
|
}
|
|
|
|
|
2021-12-23 20:44:45 +01:00
|
|
|
#if defined(__GLIBC__) || defined(__ANDROID__)
|
2019-04-30 22:54:58 +02:00
|
|
|
malloc_info(0, stdout);
|
2021-12-23 20:44:45 +01:00
|
|
|
#endif
|
2019-04-30 22:54:58 +02:00
|
|
|
}
|