newlibc memory leaks (was rtems 4.6.0pre5: memory leak after deleting a task used printf)

Till Straumann strauman at
Thu Oct 21 00:10:31 UTC 2004

Looking into this issue, as always, worms are spilling
out of the can...

I was trying to see if we could use as much 'newlib' code
as possible to cleanup the reent structure after deleting
a task. As this should be portable to newer releases of newlib,
I also checked on the current status of newlib.

It seems that newlib changed recently to maintain 'FILE' objects
and 'atexit' handlers on a 'process' rather than 'task' basis
(which makes sense, sort of).

What's the future of RTEMS? Are we continuing to close all
open files (except for stdio) on task deletion? (Note
that 'atexit' is probably flawed, currently).

Are there any known applications that rely on the current
semantics (fclose all streams on task deletion)?

For the current version (4.6 / newlib 1-11) I propose
the following fix:

  - patch _close_r() so it doesn't really shutdown descriptors 0/1/2
  - at task deletion:
     fwalk( fclose)   /* release all resources attached to FILEs        */
     _reclaim_reent() /* releases all reent memory not member of a FILE */
                      /* CAVEAT: calls 'atexit' handlers of deleted task*/

-- Till

More information about the users mailing list