rtems 4.6.0pre5: memory leak after deleting a task used printf

Valery Pykhtin pykhtin at prosoft.ural.ru
Tue Oct 19 10:35:43 UTC 2004

Hi all,

It seems there is a memory leak when deleting a task used printf.

I created the test:

1. Calculating the amount of free/used blocks in c heap using 
2. Starting new task
3. Task does printf and selfdeletes
4. Calculating the amount of free/used blocks in c heap using 
5. Comparing values before starting a task with values after.
6. Goto point 1

After each iteration the number of used blocks is continously increasing. To 
catch the bandit I created memory allocation tracer wich logs every 
_Heap_Allocate and _Heap_Free and (log include stack traces for each 
allocation) and marks those blocks that were not freed.

The stack trace of the bandit:

#0 __wrap__Heap_Allocate
#1 _Region_Allocate_segment
#2 rtems_region_get_segment
#3 malloc
#4 _malloc_r
#5 __smakebuf  at newlib/libc/stdio/makebuf.c:81
#6 __swsetup at newlib/libc/stdio/wsetup.c:63
#7 _vfprintf_r at newlib/libc/stdio/vfprintf.c:519
#8 vfprintf at newlib/libc/stdio/vfprintf.c:367
#9 printf at newlib/libc/stdio/printf.c:62
#10 TestTask

where TestTask is my test task, __wrap__Heap_Allocate  - _Heap_Allocate 

I can send the test I've used, it contains the memory allocation tracer and 
completly ready to run under debugger. My BSP is pc586. Note that the test 
uses builtin GCC functions __builtin_frame_address and 

Tommorow I'm going to repeat the test with RTEMS 4.6.2


More information about the users mailing list