LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to produce a ill legal fault? (https://www.linuxquestions.org/questions/programming-9/how-to-produce-a-ill-legal-fault-837299/)

liunxlq 10-10-2010 09:43 PM

How to produce a ill legal fault?
 
hello,
i encounter a problem with my program recently, i get the core dump of my
program, and it produced by a segill signal, i wondered that how my program can happen to generate this error, and i never write a "0 divide"
code, i have no ideas, help me please!:rolleyes:

murugesan 10-11-2010 01:59 AM

It requires the following:
Code:

ulimit -c unlimited
a.out
gdb -q coreFileName
where
frame LineNumber
print variableName


http://www.geocities.ws/murugesan/te...reExample.html

neonsignal 10-11-2010 06:52 AM

Quote:

Originally Posted by liunxlq (Post 4123376)
it produced by a segill signal, i wondered that how my program can happen to generate this error, and i never write a "0 divide"

The SIGILL is caused by the execution of an illegal instruction, which is not the same as a divide by zero error.

Typically this is caused by a stack corruption (eg writing off the end of an array that is a local variable) which corrupts the return address. There are other ways it can happen too (eg a function pointer that is not initialized).

liunxlq 10-14-2010 03:29 AM

Thanks very much!

MTK358 10-14-2010 07:17 AM

In the RAM, there is nothing that says whether a byte is an instruction or data. The CPU simply executes them one after another, jumping to a different location if that's what that certain byte happened to mean.

What happened is that you CPU tried to execute a byte that wasn't assigned any instruction hard-wired into the CPU.


All times are GMT -5. The time now is 03:48 PM.