473,473 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

fopen causing malloc error - HELP!

ld.so.1: internal: malloc failed

I'm getting the above on a simple fopen() in a production program. I
know that fopen calls malloc, but what would cause this and how do I
fix it? Have I hit some kind of # files open limit or something?

I'm running in Solaris 2.6.

Barry
Perot Systems
Nov 13 '05 #1
4 5505
Tank wrote:
ld.so.1: internal: malloc failed

I'm getting the above on a simple fopen() in a production program. I
know that fopen calls malloc, but what would cause this and how do I
fix it? Have I hit some kind of # files open limit or something?


More likely, a bug elsewhere has trashed malloc's bookkeeping. You need
to find that bug and fix it.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgrou...mp.lang.c.html
C welcome: http://www.angelfire.com/ms3/bchambl...me_to_clc.html
Nov 13 '05 #2
Kn****@hotmail.com (Tank) wrote:
ld.so.1: internal: malloc failed

I'm getting the above on a simple fopen() in a production program. I
know that fopen calls malloc, but what would cause this and how do I
fix it? Have I hit some kind of # files open limit or something?


Possibly, but one would expect that to give a more legible error
message. It's rather more likely that you have, somehow, played havoc
with the allocation arena earlier on in the program, and what you're
seeing here is merely secondary damage.
Since we know nothing about your program it is impossible to be more
specific, but it would probably be a good idea to check your malloc()
and free() (and related) calls, perhaps with the aid of an allocation
checker.

Richard
Nov 13 '05 #3

"Tank" <Kn****@hotmail.com> wrote in message

I'm getting the above on a simple fopen() in a production program. I
know that fopen calls malloc, but what would cause this and how do I
fix it? Have I hit some kind of # files open limit or something?

Comment out all your code except the call to fopen(), and see if it still
fails. If it does then there is probably something wrong with the file or
the path to it.

Other posters have suggested that you may have corrupted the malloc()
system. Replace the call to fopen() with a call to malloc(). If the malloc()
fails, then this is almost certainly the problem. Unfortunately if the
malloc() succeeds you haven't proved that the malloc() system is not
corrupt.

Comment in code until the bug reappears. Comment out code again until you
have isolated a small section which seems to cause the bug. This will
probably lead you to the problem.
Nov 13 '05 #4
"Malcolm" <ma*****@55bank.freeserve.co.uk> wrote:

"Tank" <Kn****@hotmail.com> wrote in message

I'm getting the above on a simple fopen() in a production program. I
know that fopen calls malloc, but what would cause this and how do I
fix it? Have I hit some kind of # files open limit or something?

Comment out all your code except the call to fopen(), and see if it still
fails.


Erm. Commenting out _all_ code except the fopen() call will leave you
with an uncompilable one-liner...

Richard
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Patrice | last post by:
Hi, I would to call fopen function several time in my application. This application permits to read files which path is registered in a configuration file. For exemple: File 1 = toto.txt File 2...
1
by: Dawn Minnis | last post by:
Hey guys - this code when called with parameters: driver.o n n 12 12 12 12 12 12 2.6 3.2 is kicking back a segmentation fault. I've read the rest of the postings but am still confused. Can...
19
by: lihua | last post by:
Hi, Group! I got one question here: We all know that fclose() must be called after file operations to avoid unexpected errors.But there are really cases when you forget to do that!Just like...
39
by: ferrad | last post by:
I am trying to open a file for appending. ie. if the file exists, open it for appending, if not, create it. I am getting back a NULL pointer, and do not know why. Here is my code: FILE...
4
by: Chris | last post by:
This is the code: ###################### #include <stdlib.h> using namespace std; class intlist { unsigned int length; int * list; public: intlist() {
25
by: subramanian100in | last post by:
Consider the following program: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { if (argc != 2) { printf("Usage: <program-name<text-file>\n");
3
by: IamtheEvster | last post by:
Hi there, I'm using fopen for the first time and I know I'm running into a permissions problem, but I can't seem to resolve it and any help would be greatly appreciated. I'm running PHP5 and...
3
by: pochipp | last post by:
Hi.. All I got a problem in writing this program becoz I successfullly compiled the file but I cannot run the program since there will be an error when I run it. So I checked again... And there...
20
by: cscorley | last post by:
For some reason, I cannot use fopen() on the file in write mode. The file "time" is in the same directory as the .php file, with permissions set to 0766. PHP Version 5.2.5 Apache/2.2.8 code...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.