Hi Fabrizio,
Hi Fabrizio,
I see you're getting some issues with the fact that mmap calls malloc() for its underlying reservation allocation. You're correct: it should not be doing this, and ideally there should be an object cache involved in here to handle allocation of metadata objects needed by the virtual memory management implementation.
Please wait a while and there should be a patch out soon to hopefully resolve this.
--Kofi Doku Atuah
Kernel engineer
DATA61 | CSIRO
From: Devel <devel-bounces@sel4.systems> on behalf of Fabrizio Bertocci <fabriziobertocci@gmail.com>
Sent: 26 July 2017 07:34
To: devel@sel4.systems
Subject: [seL4] Recursive call to malloc crash systemHi all,I have a system configured to use dynamic heap through the vspace. I'm working with 5.2.0 and using pc99 simulator through qemu.
Everything is occurring in the root task, as I haven't even completed my bootstrapping code.
In this configuration, whenever my code calls malloc() and there is a low memory condition (where there is not enough space on the heap to fulfill my request), malloc() end up calling __expand_heap().
Here it first attempts to expand the heap through brk syscall, then if fails uses mmap() to attempt to get more pages from the virtual memory.
In both cases (brk and mmap) end up calling a function in the vspace that attempts to make available new pages.Unfortunately the code in the libself4utils/src/vspace/vspace.c, end up calling malloc() for the sel4utils_res structure.
As you expect, we are already in a no-memory condition, so a subsequent call to malloc() might end up calling __expand_heap() and so on... (depending on the bytes left on the heap, this nested malloc might succeed if the initial block was larger than the size of sel4utils_res structure).
So, everything loops until the whole system crash because of stack overflow.
Why vspace uses malloc() to dynamically allocate those structures, causing the whole system to fail?
To test, I have changed the implementation in vspace.c to use a static buffer pool, and it seems it solve my issue, but am I doing something wrong in the bootstrap code ?
Any help is appreciated,Regards,Fabrizio Bertocci
Real-Time Innovations, Inc.Sunnyvale, CA
_______________________________________________
Devel mailing list
Devel@sel4.systems
https://sel4.systems/lists/listinfo/devel