C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

malloc call not returning

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language
View previous topic :: View next topic  
Author Message
Norbert Leister
Guest





PostPosted: Wed May 02, 2007 9:11 am    Post subject: malloc call not returning Reply with quote



Hi NG,

I've the problem, that a malloc call is not returning.

<source-snip>

printf("a\n");
my_pointer = (struct_pointer)malloc(struct_size); /*size 1420*/
printf("b\n");
</source-snip>

I'm almost sure, that my program frees some memory, but if there is no
memory, the malloc should return some NULL-pointer.

The 'normal' output of the function is 'a' and 'b'. But sometimes (after
a while of running), the program stops after printing the 'a'. The other
threads of the programm are still responding to commands, but the one
who called the malloc does not reacts.

Have you somewhere had a similar problem?
Compiler: gcc-3.3.3-7 on Fedora Core 2


Greeting:


Norbert
Back to top
Ian Collins
Guest





PostPosted: Wed May 02, 2007 9:11 am    Post subject: Re: malloc call not returning Reply with quote



Norbert Leister wrote:
Quote:

Hi NG,

I've the problem, that a malloc call is not returning.

source-snip

printf("a\n");
my_pointer = (struct_pointer)malloc(struct_size); /*size 1420*/
printf("b\n");
/source-snip

I'm almost sure, that my program frees some memory, but if there is no
memory, the malloc should return some NULL-pointer.

The 'normal' output of the function is 'a' and 'b'. But sometimes (after
a while of running), the program stops after printing the 'a'. The other
threads of the programm are still responding to commands, but the one
who called the malloc does not reacts.

Have you somewhere had a similar problem?
Compiler: gcc-3.3.3-7 on Fedora Core 2

Attach your debugger and see what the application is doing.


--
Ian Collins.
Back to top
Peter Nilsson
Guest





PostPosted: Thu May 03, 2007 9:11 am    Post subject: Re: malloc call not returning Reply with quote



Richard Heathfield <r...@see.sig.invalid> wrote:
Quote:
Flash Gordon said:
...
You are still using the wrong tool for the job. If you
want you[r] C code analysed use a tool designed to
analyse C code, not a tool designed to compile C++
code.

No, Flash, he's right - if he wants more warnings, using a
compiler for a different language is a great way to get
them. Personally, for this purpose I can wholeheartedly
recommend using a COBOL compiler.

If only you had recommended that to dmr 20 years ago.

--
Peter
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.