Anyway to debug

Started by
6 comments, last by Codarki 13 years, 9 months ago
Hey,

I have a program, that crashes with:
Program received signal SIGILL, Illegal instruction.

And I have not Idea of how to debug the problem. I fired up gdb, the error occurs on this line:

thinking=false;

"thinking" is a perfectly fine (member)variable of type bool.
- *this seems to fine and initialized corretctly.
- The stack backtrace seem also to be fine.

I know, you can not debug my problem. But I was wondering if anyone has any hint on how to find out more about a problem like this.

Thanks!
Nathan
Advertisement
If I had to make a guess I'd say you were overrunning a buffer somewhere. Overwriting the assignment with something garbage. Are you using char*'s? Are you manually futzing about with arrays and the such?

Quick visual inspection is probably enough for that sort of thing depending on the die of your code.
Quote:Original post by LonelyStar
Hey,

I have a program, that crashes with:
Program received signal SIGILL, Illegal instruction.

And I have not Idea of how to debug the problem. I fired up gdb, the error occurs on this line:

thinking=false;

"thinking" is a perfectly fine (member)variable of type bool.
- *this seems to fine and initialized corretctly.
- The stack backtrace seem also to be fine.

I know, you can not debug my problem. But I was wondering if anyone has any hint on how to find out more about a problem like this.

Thanks!
Nathan


if you use gdb, just make breakpoint somewhere where variable thinking is still valid and add watch to it.
gdb stops everytime watched variable is changed, it should do that even if someone is overwritting its memory locaction.


Elaborating on Telastyn's answer: I would look at the binary code corresponding to that assignment when the program is loaded, and look at it again when the crash happens. Chances are it has been modified. Perhaps you can get the debugger to tell you when the modification happened (I think some incantation involving awatch in gdb can do that for you).

It may also be that somehow you're using a class instance that doesn't exist anymore. When the crash occurs, can you check that the instance doing that member assignment is a valid instance of the class?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Hey guys,

Thanks for all the answers.
I ran the program through valgrind. If it would change its own code, there must be an invalid write somewhere, or not?

There is non!
- How can I look at binary code corresponding to the assignment? Sounds like a great idea, but how do I do that?
- I can type *this and get a valid answer. Does this ensure, that the current instance exists/is valid? If not, how can I check it?
If you are running function f, type the following in the gdb prompt:
(gdb) disassemble f


That should be useful.
First of all, is this single threaded?

I have not much experience with gdb, but some debuggers misses one line. Though if this is a small function, i doubt posting it is that much helpful. I think the problem is somewhere else.

Illegal instruction very much points to data (within code segment) being modified. Unless the compiler generates bad code, which is _very_ unlikely.

But I think you can set a breakpoint for memory changes, like Alvaro described. I'm sure you'll catch that bugger :)

This topic is closed to new replies.

Advertisement