bugAVR C Runtime Library - Bugs: bug #12557, Non-reentrancy in malloc affects...

 
 

bug #12557: Non-reentrancy in malloc affects fprintf, sscanf, etc...

Submitted by:  None
Submitted on:  Tue 05 Apr 2005 02:16:22 AM UTC  
 
Category: LibrarySeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedPercent Complete: 0%
Assigned to: Joerg Wunsch <joerg_wunsch>Originator Email: -unavailable-
Open/Closed: ClosedRelease: None
Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 06 Sep 2005 07:53:03 PM UTC, comment #1:

With the recent addition of a malloc()-free stdio API, this
is believed to be fixed as a side-effect.

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Tue 05 Apr 2005 02:16:22 AM UTC, original submission:

Hi,

I am currently using the runtime library that accompanies WinAVR with my own pre-emptive RTOS. I have used fdevopen() to direct output to a serial port and an LCD. It is possible for a task that writes to the LCD to be preempted by a task that writes to a serial port, and vice-versa, and either could preempt a user input task that uses sscanf. This is all perfectly reasonable and normal in an embedded system.

Looking at fdevopen(), vfprintf() and vfscanf(), I notice that they all (indirectly) call malloc() (in the latter two cases, when using floating point numbers). This appears to be somewhat problematical, as malloc() does not appear to be reentrant. As far as I can determine, it appears to be possible for one task that is partway through walking the freelist to be preempted by another task that then alters the freelist, before resuming the first task.

I hope that I am wrong, and do not have to implement a workaround*.

I would appreciate your opinion as to whether or not this is a genuine issue.

Kind regards,
Tanya Cumpston

*(The workaround would consist of writing substitutes for the above stdio routines, which attempt to secure a semaphore before calling the existing library routines, then using #defines to redirect calls to the existing library routines to the substitute routines.)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Updated the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 22 Oct 2007 10:42:48 AM UTCjoerg_wunschPrivacyPrivate=>Public
    Tue 06 Sep 2005 07:53:03 PM UTCjoerg_wunschStatusNone=>Fixed
      Assigned toNone=>joerg_wunsch
      Open/ClosedOpen=>Closed
    Tue 05 Apr 2005 02:16:22 AM UTCNoneCarbon-Copy-=>Added tcumpston --AT-- bigpond --DOT-- com

    Back to the top


    Powered by Savane 3.1-cleanup1