Hottest Free Downloads - DownloadPipe.com Over 197,000 downloads! Bookmark Now!
DownloadPipe.com - New Downloads Every Minute
 SEARCH:
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Bug in alloc.c?

 
   Mac (Home) -> Programmer Code RSS
Next:  Bank of Sweden Treasury - Strategic Infrastructur..  
Author Message
Keith Wiley

External


Since: Sep 02, 2006
Posts: 43



(Msg. 1) Posted: Fri May 27, 2005 1:49 pm
Post subject: Bug in alloc.c?
Archived from groups: comp>sys>mac>programmer>codewarrior (more info?)

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 DeleteThis @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
________________________________________________________________________
Back to top
Login to vote
Howard Hinnant

External


Since: May 27, 2005
Posts: 1



(Msg. 2) Posted: Fri May 27, 2005 8:31 pm
Post subject: Re: Bug in alloc.c? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <Pine.LNX.4.60.0505271341480.12157 RemoveThis @ramon.cs.unm.edu>,
Keith Wiley <kwiley RemoveThis @cs.unm.edu> wrote:

> 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?

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
Back to top
Login to vote
Keith Wiley

External


Since: Sep 02, 2006
Posts: 43



(Msg. 3) Posted: Sat May 28, 2005 12:50 am
Post subject: Re: Bug in alloc.c? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

On Fri, 27 May 2005, Howard Hinnant wrote:

> In article <Pine.LNX.4.60.0505271341480.12157.RemoveThis@ramon.cs.unm.edu>,
> Keith Wiley <kwiley.RemoveThis@cs.unm.edu> wrote:
>
>> 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?
>
> 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 kwiley.RemoveThis@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
________________________________________________________________________
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Multiply defined symbol: .bss - Hi, when trying to build a dll for Windows using CW9 on MacOS, I get an error message like: Link Error : Multiply defined symbol: .bss in files file1.cpp, file2.cpp The same message with the same filenames is repeated several times, but....

Where next? - Hi folks, All of my recent Mac coding has been Carbon C++, mostly using PowerPlant as a framework. As most of my clients are moving to X and CW's future is, shall we say, uncertain I'm wondering where to look for my future coding setup. I've dabbled....

Does mwcc work on Tiger? - Anybody using the comand line compilers on 10.4? When saving the following simple program as /tmp/x.cpp: int main() { double x = 0.5; return 0; } and trying to compile it with $ mwcc -c /tmp/x.cpp , I get the error message Error :....

Console app "file" selector - Hello, I feel like I've asked this before, but I did a search on the archives and came up short. I've got a console std c app that I'm compiling with CW. When it runs, it pops up a little menu where I can type in some command line arguments (for..

CodeWarrior 9.5 - Where can I download it? Thanks Felix
       Mac (Home) -> Programmer Code All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
 Linux Forums
  Mac Forums
 PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact