Hi! I have some problems with memory allocation. I create new thread in cidir storage and call malloc(), and it fails to allocate even 1 byte. What can cause this problem?
Dovecot vesrion is: 2.1.10 (130563b592c9+)
Sample code looks like this (I also link to pthread with: -pthread):
#define TEST_MALLOC()
{
void *p;
p = malloc(1);
if (!p) {
i_info("%s: malloc() failed", __FUNCTION__);
} else {
i_info("%s: malloc() succeeded", __FUNCTION__);
free(p);
}
}
#include
static void *test_pthread_malloc_func(void *data_) { TEST_MALLOC(); return NULL; }
static void test_pthread_malloc() { int ret; pthread_t tid; TEST_MALLOC(); ret = pthread_create(&tid, NULL, test_pthread_malloc_func, NULL); if (ret) { i_info("failed to start thread"); } else { pthread_join(tid, NULL); } }
I call test_pthread_malloc() function. It produces following output:
Oct 11 12:56:15 imap(guest): Info: test_pthread_malloc: malloc() succeeded Oct 11 12:56:15 imap(guest): Info: test_pthread_malloc_func: malloc() failed