Re: Illegal instruction (core dumped)

From: glen herrmannsfeldt (gah_at_ugcs.caltech.edu)
Date: 05/11/04


Date: Tue, 11 May 2004 17:34:42 GMT

James Van Buskirk wrote:

(snip regarding "Illegal instruction (core dumped)")

> It means that a machine-level instruction mnemonic was issued
> that didn't correspond to any machine-level mnemonic known to
> the current processor. One way this could happen is that code
> was compiled for a different processor than it was actually
> run on, but most frequently some instructions would be placed
> in the executable prolog that would result in a more user-
> friendly diagnostic in this case.

> More commonly an instruction was issued to the processor that
> wasn't part of the compiled code either by:
> 1) overwriting the compiled code by writing to an invalid array
> index (although in many environments this would be trapped
> and you would get a segmentation fault or a bus error rather
> than surviving to issue an invalid instruction)

While this is possible on many machines, I don't believe that
I have ever known it to actually cause this problem.

> 2) jumping to an unanticipated address by either
> 2a) associating a data actual argument with a procedure dummy
> argument or

This one I used to know as very common for beginning Fortran
programmers. It is somehow not obvious that arrays need to be
DIMENSIONed in both main and called subroutines. The effect of
forgetting the DIMENSION in a subroutine is that the compiler
assumes is is being passed a function address, and that array
references are actually function references. If no assignments
to such an array exist, the program can easily compile without
any compile time errors.

> 2b) messing up the stack (kind of requires a compiler that
> has a callee cleans up the stack calling convention, in
> which case invoking a procedure with the wrong number of
> arguments or the wrong number of character arguments
> could do the trick.)

Another reason I don't like the callee clean up convention.

(snip)

-- glen



Relevant Pages