This is the mail archive of the newlib@sourceware.cygnus.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

reentrancy and fclose.c



Hi,

One of the RTEMS users was looking at fclose and is concerned about the
possibility of multiple tasks attempting to close the same FILE
simultaneously.  In his scenario, task A blocks while doing the fflush()
and task B begins to execute fclose() on the same FILE.

If newlib's reentrancy features are in use (which they are in this case),
will this be safe?  If so, why?

We see one of the tasks returning from fflush() first and freeing all the
memory.  The second task gets stale pointers and tries to free those
buffers.  We suppose that the worst case would be that the buffers get
reallocated before the second task gets its shot at freeing them.

Comments...

--joel
Joel Sherrill                    Director of Research & Development
joel@OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (205) 722-9985