1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

fix: limit preallocate stack size

If the user would set bigger reserved stack size then what
is allowed in resources (ulimit -s), then he would get coredump
So avoid coredump and ignore creation of such large stack size
(lvm should work properly, with just 64KB, so the option could
be eliminated).
This commit is contained in:
Zdenek Kabelac 2012-06-22 11:15:14 +02:00
parent 192fa11dab
commit 2539769356

View File

@ -124,8 +124,12 @@ static void _touch_memory(void *mem, size_t size)
static void _allocate_memory(void)
{
void *stack_mem, *temp_malloc_mem;
struct rlimit limit;
if ((stack_mem = alloca(_size_stack)))
/* Check if we could preallocate requested stack */
if ((getrlimit (RLIMIT_STACK, &limit) == 0) &&
((_size_stack * 2) < limit.rlim_cur) &&
((stack_mem = alloca(_size_stack))))
_touch_memory(stack_mem, _size_stack);
if ((temp_malloc_mem = malloc(_size_malloc_tmp)))