This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug Report: Illegal Instruction


   >    Could it be a buffer overflow problem?
   
   > I do not consider myself a buffer-knowledgable person, but I don't
   > think its a buffer overflow problem.
   
   Run it within a debugger and see how it crashes.  If it's a totally
   strange address, odds are that you've inadvertently overwritten part
   of the stack by overrunning a fixed-size buffer.

Glad to take suggestions on how to solve this.  Really.

I had previously ran it with a debugger (gdb 4.1.6).  Here's the
result: 

"Program received signal SIGILL, Illegal instruction.
0x0 in ?? () from /nfs/user/b/billl/test/notwork/TABLE
(gdb)"

Certainly looks like the program/debugger *totally* lost its way
somewhere.  I could not then use any of the debugger feature (e.g., 
print a variables value or see what line of source code it was on).  
Is this what you mean as an implication that a fixed size buffer
overan the stack?  If so, then what buffer?  The one associated with
screen output (i.e., cout)?

But my coding seems to have cleared the screen output buffer
essentially three characters prior to the error (i.e., used "endl").  
Also, note that eliminating output of the first row, the column
headings, did not change the location of the error with respect to
screen output.  That doesn't sound like a screen output buffer problem
since I effectively made a 50% cut in what goes to the screen before
the error ... and still had the same problem in the same place.  It
was only when I eliminated the second row that the problem moved to
the start of the fourth row.

So far, the problem consistantly occurs at the end of a cycle that
goes a) print a string, b) print a bunch of numbers, c) send an endl,
and d) print a string.  All of these except the endl occur in a couple
of different switch cases.  These occur within two for-loops roughly
as follows

   for-loop 1
      for-loop 2
        switch
        case I:  // string output w/ formatting
        ...      // error occurs in here
	case II: // integer output w/ formatting
        ...
        case III:
        end switch
      end for-loop 2
      cout << endl;
   end for-loop 1

Outputs a) and b) occur as for-loop 2 increments over its control
variable.  Output c), the endl, occurs after a run of for-loop 2 and
before for-loop 1 sends for-loop 2 through another run.  So, cases I
and II are executed one or more times in a single run of for-loop 2
and the error occurs in case I at the start of the next running of
for-loop 2.

By the way, my work-around was to take all the basic instructions out
of the switch case and put them into a function.  Then, the code
called the function from within the switch case.  Would making such a
function call clear/reset the screen output buffer?  It's not what I
would expect but I may not understand.

Are there other types of fixed-size buffers that you have in mind
besides screen output?

Again, I do appreciate the suggestions.  I do not mind at all being
the one to do the physical trouble shooting.  I would be as happy to
find an error in my code as in the compiler.  :)

Bill


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]