segfault with getc
Any time I use a file over 3megs I end up getting seg faults in my application. I have been allover this with gdc no luck. At first I thought it might just be not reserving enough memory to handle a 3meg file, but now I don't see anywhere where this is reserving memory to be an issue.. Any help would be awesome
this block of code has the getc with in the while that is causing the seg fault.. the file is defined as file *infile and then pointed to argv 1 No code modifies or does anything with *infile till I get to the line that is broken.. Code:
|
What type of response are you looking for wrt the problem? It's hard to deduce; here's why...
1. You are using global variables of which you have not shown their declared types; 2. You are calling functions for which we know nothing about, much less what they serve; 3. Your code is written in a condensed format, as almost if your <return> key was broken half the time; 4. Your code lacks comments, and bears hard-coded numbers, which represent selectively chosen ASCII values. Thus in conclusion, you pleas re-edit your OP to fill in the blanks? Perhaps even show the complete code. |
amazing as soon as I posted this the answer came to me. so disregard I guess.
|
Quote:
3,4,I am not the original scribe for this application I am just trying to fix it.... None the less I found my issue so its taken care of thanks for the input though, I realize my post lacks a lot of sustenance, but I was doubting if I should even post it due to the volume of source code involved and thus was unsure of a good method to get my idea across. Apologies. |
That's alright. But when facing issues with a large application, if possible, try to whittle down the code to the area causing the problem, and try to incorporate this into a mini-application that can easily be tested.
Please mark this thread as SOLVED as a favor to others. |
Quote:
But it seems obvious from the posted code in this thread that was not the case. The area experiencing the symptom (seg fault) was not the area causing the problem. I expect that once the OP knew what section of code was causing the problem, that was the solution. So asking to isolate the problem code in a small program is harder than asking to solve the problem. That's why serious programmers need to learn how to debug: What got stepped on: The pointer (infile)? Or the structure it points to? Or deeper parts of the I/O system, it depends on? Once you know what got stepped on, a data breakpoint brings you to the code that stepped on it. There are often extra complications, but reproducible seg faults can be systematically identified. Meanwhile trying to isolate the point of symptom into a self contained program is a waste of effort (other than for beginner situations mentioned above). The cause will almost certainly be elsewhere. |
All times are GMT -5. The time now is 07:45 PM. |