?
Solved

Segmentation fault(Core Dumped)

Posted on 2003-03-05
6
Medium Priority
?
632 Views
Last Modified: 2013-12-06
Hi,

I am trying to read a very large file (32 GB) in C language on Solaris platform. The program processes upto 30GB and then crashes by displaying this message

"Segmentation fault(Core Dumped)"

I need some experts' help for this. Any help in this regard will be appreciated.

[Note : The program is compiled with gcc on Solaris.]

Thanks
Sant Singh
0
Comment
Question by:santsingh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 8076471

That's a really strange place in the I/O of the file for it to blow up!  You've obviously read millions of records and still plugging along.  But here's some things to check:

1)  Are you reading fixed length blocks or lines of text?  If you're reading lines of text MAKE SURE that the buffer is at least 2 characters longer than the longest line that you expect to read and that the record length in the fread() is shorter than the buffer length.  Also make sure that you use fread() and NOT fgets().

2)  How much memory managment (malloc(), free()) are you performing between reads?  While there is no problem mixing I/O and memory management, you could be allocating a buffer that's too small.

3)  Do you know the contents (or line number) where the application is bombing?  Make sure that the data at that location is not corrupt.


Sorry I can't give specifics, but there are pretty good general places to start.

Kdo
0
 

Author Comment

by:santsingh
ID: 8081950
Thanks Kdo

I am using fread (buffer,1,sizeof(usage_struct),pFile) to read the record. The Record is of fixed length.

Memory to the structure is allocated only once before entring into the loop and the same structure is used in the loop.

The contents are in a binary file and I cannot verify by manually looking at it. Is there some wayto verify this.

I tried the smaller file and found that it is processing upto end but it crashes at the last record. The 30 GB which is processed is actually the size of the ouput file (a ascii file generated as output by the program).

Thanks
Sant Singh

0
 

Author Comment

by:santsingh
ID: 8084073
Thanks Kdo

I am using fread (buffer,1,sizeof(usage_struct),pFile) to read the record. The Record is of fixed length.

Memory to the structure is allocated only once before entring into the loop and the same structure is used in the loop.

The contents are in a binary file and I cannot verify by manually looking at it. Is there some wayto verify this.

I tried the smaller file and found that it is processing upto end but it crashes at the last record. The 30 GB which is processed is actually the size of the ouput file (a ascii file generated as output by the program).

Thanks
Sant Singh

0
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 46

Expert Comment

by:Kent Olsen
ID: 8084117

"The last record" -- that's usually a pretty telling event.

Check your end-of-file processing.  make sure that you close the file and drop any buffers after processing the data.

Perhaps end-of-file processing uses your input structure (buffer) for some other purpose and overflows it?

I don't know what trace capabilities you've got.  I think that I'd start by creating a test file that consists of the last 3 or 4 records and process it.  The add a few printf() statements to the code until you isolate the problem.


Good Luck,
Kent
0
 
LVL 12

Expert Comment

by:paullamhkg
ID: 9229459
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is to:

Be PAQ'd/Points No Refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Paul
EE Cleanup Volunteer
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 9290621
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question