PDA

View Full Version : Really strange segmentation fault



codemonkey
19th January 2010, 09:59
I get a really strange segmentation fault and I've got no idea why I keep getting it.

If I would strip down the code (and move everything from .cpp file to .h file) , all that would remain is

class App:public QObject{
Q_OBJECT
public:
App(){}
void foo(){m_authenticated = false;}
private:
bool m_authenticated;
}


(it is too much code to post here so I hope this will be enough, else I will put the code on the net somewhere to download)

Now the problem is that the call to foo gives me a segmentation fault exactly when I try to access m_authenticated. I have no clue why. Do you? (I've tried the same thing with an int, and it fails. it also fails if it is declared public).

Any guesses or suggestions on how to debug?

codemonkey
19th January 2010, 10:20
When I ran the debugger and added a watch it said: not in scope (when I was inside of foo())!

caduel
19th January 2010, 11:41
Check that the object you call foo() upon is valid (i.e. esp not the 0-pointer).
Or: Your error is somewhere else; C/C++ has the nice property that you can overwrite any memory, including the stack, so the debugger's stack trace might be damaged, too.

(The information, meaning source, you provide, is not enough to track the error down.)

squidge
19th January 2010, 14:19
How do you call foo? You've pasted just the class definition.