Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / May 2005



Tip: Looking for answers? Try searching our database.

Bug in alloc.c?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Wiley - 27 May 2005 20:49 GMT
I'm getting an infinite loop in alloc.c, which is located in
MSL/MSL_C/MSL_Common/Src.  This is with CW 9.5.  The function is
allocate_from_var_pools.  There is a do/while loop that searches for a
block with the required size to allocate a block of memory.  I got to this
point through new, not malloc, in my own code.  My new requests 16384
floats, which new translates to 65536 (four bytes per float) but which
alloc first converts to 65552 before starting the do/while loop.  After
that, the loop starts trying to find a block.  In other situations in my
program, this allocation works, but in one reproducible situation the loop
becomes infinite, meaning it neither finds a block, nor ever breaks out
with a failed allocation.  It should be noted that there is plenty of free
memory on my computer, and we're only talking about 65k here.

Any thoughts?

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
Howard Hinnant - 27 May 2005 21:31 GMT
> I'm getting an infinite loop in alloc.c, which is located in
> MSL/MSL_C/MSL_Common/Src.  This is with CW 9.5.  The function is
[quoted text clipped - 10 lines]
>
> Any thoughts?

You've got my attention (I wrote this code).  The most common cause of a
situation like this is heap corruption from client code.  However it is
always possible that there is a bug in malloc.  This malloc
implementation is purposefully not robust in order to maximize
performance and to make heap corruption bugs as visible as possible.

The heap is a doubly linked and circular list of memory chunks.  The
behavior you describe indicates that the circularity of this chain has
been compromised, perhaps it has been short circuited such that
pool_obj->start_ no longer points anywhere into that circle.  After
making one circle around the chain, the loop should give up and go to
the OS for more memory.

If you could create a demo that you would be willing to mail me, I'd be
happy to look at it.  You could also try plugging in a debug new or
malloc which might catch an earlier bug.  There's one here you are
welcome to try:

http://home.twcny.rr.com/hinnant/MemoryManager/

-Howard
Keith Wiley - 28 May 2005 07:50 GMT
Thanks.  It sounds from your description like there is a fair chance my
program is causing the problem at some earlier stage.  I wouldn't be
surprised if that were the case.  I'll study it a little further before
bothering you with it.

Thanks.

>> I'm getting an infinite loop in alloc.c, which is located in
>> MSL/MSL_C/MSL_Common/Src.  This is with CW 9.5.  The function is
[quoted text clipped - 32 lines]
>
> -Howard

________________________________________________________________________
Keith Wiley         kwiley@cs.unm.edu         http://www.unm.edu/~keithw

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
                                           --  Edwin A. Abbott, Flatland
________________________________________________________________________
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.