[Dovecot] memory allocation in new thread
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
On 11.10.2012, at 13.21, . . wrote:
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?
No idea. Dovecot in general isn't designed to work with threads.
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
Well, or the one thing I can think of you to try: Set default_vsz_limit=0
Also straceing the process could show what exactly fails.
participants (2)
-
. .
-
Timo Sirainen