Hi again,

I found the bug. I had two pointers to the same object, that's why the 
constructor was called twice. So it is obvious that there is an error.

But I expected the error much earlier -- when deleting the object behind 
pointer for the second time. But it seems that in both ways, debugging 
and running, the object is still in memory. While running, completely, 
and, while debugging, only partly.

Regars
Paul.

On 12/28/2010 17:31, Paul Wellner Bou wrote:
> Hello,
>
> I experience a strange SIGSEGV debugging my Qt application: I only get
> the SIGSEGV while running the code with the "Debug" button. Running it
> with the "Run" button is fine. This is reproducable. I tried it a lot of
> times, recompiled in between, tried it then with the Qt Creator 2.1 RC
> 1, and so on. (Windows XP.)
>
> For debugging purposes I printed out the address of the (private)
> pointer (The SIGSEGV occurs in a destructor, where I try to delete my
> pointers allocated in the methods of the class during runtime):
>
> When running: 0x0
> When debugging: 0xfeeefeee
>
> Furthermore, I commented out all the code doing something with this
> pointer. And the pointer is initialised with 0 in the constructor. Still
> the same error, although it should be 0 through the whole runtime.
>
> Beside the fact, that there is a bug in my code (the constructor is
> called twice and it shouldn't), This should not happen, correct?
>
> The only explanation I can imagine would be that somehow the destructor
> is called twice at almost the same time and as running is faster than
> debugging, the pointer is set to 0 before the second destructor tries to
> delete it. But even introducing a 0 check before deleting it, this happens.
>
>
> // Ctor
> Triangles::Triangles() : p(0)
> {
> }
>
> // Destructor
> Triangles::~Triangles()
> {
>       qDebug()<<  this->p;
>       if(this->p != 0)
>           delete [] this->p; //<-- I get the SIGSEGV in this line
> }
>
> Regards
> Paul.
> _______________________________________________
> Qt-creator mailing list
> [email protected]
> http://lists.qt.nokia.com/mailman/listinfo/qt-creator
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-creator

Reply via email to