Getting segmentation fault on close of my application.
-
Hi Experts,
I am getting segmentation fault on close of my application. I tried to debug the issue but could not see any issue. So seeking help to understand the problem.Background of my program:
It is a multithreaded program which is trying to download an XML file from server in separate thread. It is working fine but when I am closing the application it is giving segfault. I have given the call stack, please take a look.Call stack:
#0 0x00007ffff4ecf360 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff54c24cd in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007ffff670a186 in QMutex::QMutex (this=0x25276d0, mode=QMutex::NonRecursive)
at thread/qmutex.cpp:124
#3 0x00007ffff670e10d in QPostEventList::QPostEventList (this=0x25276b8) at thread/qthread_p.h:110
#4 0x00007ffff670d0d2 in QThreadData::QThreadData (this=0x2527690, initialRefCount=1)
at thread/qthread.cpp:81
#5 0x00007ffff67103b0 in QThreadData::current () at thread/qthread_unix.cpp:222
#6 0x00007ffff684a35b in QObject::QObject (this=0x25274b0, dd=..., parent=0x0) at kernel/qobject.cpp:773
#7 0x00007ffff670da3e in QThread::QThread (this=0x25274b0, dd=..., parent=0x0) at thread/qthread.cpp:385
#8 0x00007ffff670d479 in QAdoptedThread::QAdoptedThread (this=0x25274b0, data=0x2527340)
at thread/qthread.cpp:137
#9 0x00007ffff67103fd in QThreadData::current () at thread/qthread_unix.cpp:225
#10 0x00007ffff684a35b in QObject::QObject (this=0x2527160, dd=..., parent=0x0) at kernel/qobject.cpp:773
#11 0x00007ffff670da3e in QThread::QThread (this=0x2527160, dd=..., parent=0x0) at thread/qthread.cpp:385
#12 0x00007ffff670d479 in QAdoptedThread::QAdoptedThread (this=0x2527160, data=0x2526ff0)
at thread/qthread.cpp:137
#13 0x00007ffff67103fd in QThreadData::current () at thread/qthread_unix.cpp:225
#14 0x00007ffff684a35b in QObject::QObject (this=0x2526e10, dd=..., parent=0x0) at kernel/qobject.cpp:773
#15 0x00007ffff670da3e in QThread::QThread (this=0x2526e10, dd=..., parent=0x0) at thread/qthread.cpp:385
#16 0x00007ffff670d479 in QAdoptedThread::QAdoptedThread (this=0x2526e10, data=0x2526ca0)
at thread/qthread.cpp:137
#17 0x00007ffff67103fd in QThreadData::current () at thread/qthread_unix.cpp:225
#18 0x00007ffff684a35b in QObject::QObject (this=0x2526ac0, dd=..., parent=0x0) at kernel/qobject.cpp:773
#19 0x00007ffff670da3e in QThread::QThread (this=0x2526ac0, dd=..., parent=0x0) at thread/qthread.cpp:385
#20 0x00007ffff670d479 in QAdoptedThread::QAdoptedThread (this=0x2526ac0, data=0x2526950)
at thread/qthread.cpp:137
#21 0x00007ffff67103fd in QThreadData::current () at thread/qthread_unix.cpp:225
#22 0x00007ffff684a35b in QObject::QObject (this=0x2526770, dd=..., parent=0x0) at kernel/qobject.cpp:773
#23 0x00007ffff670da3e in QThread::QThread (this=0x2526770, dd=..., parent=0x0) at thread/qthread.cpp:385
#24 0x00007ffff670d479 in QAdoptedThread::QAdoptedThread (this=0x2526770, data=0x2526600)
at thread/qthread.cpp:137
#25 0x00007ffff67103fd in QThreadData::current () at thread/qthread_unix.cpp:225
#26 0x00007ffff684a35b in QObject::QObject (this=0x2526420, dd=..., parent=0x0) at kernel/qobject.cpp:773
#27 0x00007ffff670da3e in QThread::QThread (this=0x2526420, dd=..., parent=0x0) at thread/qthread.cpp:385
#28 0x00007ffff670d479 in QAdoptedThread::QAdoptedThread (this=0x2526420, data=0x25262b0)
at thread/qthread.cpp:137
#29 0x00007ffff67103fd in QThreadData::current () at thread/qthread_unix.cpp:225
#30 0x00007ffff684a35b in QObject::QObject (this=0x25260d0, dd=..., parent=0x0) at kernel/qobject.cpp:773
#31 0x00007ffff670da3e in QThread::QThread (this=0x25260d0, dd=..., parent=0x0) at thread/qthread.cpp:385
#32 0x00007ffff670d479 in QAdoptedThread::QAdoptedThread (this=0x25260d0, data=0x2525f60) -
I noticed, this issue comes only when I close the application while threads are still running. Once thread execution is over issue does not come. It looks like some how I have to stop the thread and remove the event loop so that no signal/slots gets called after deletion of main object.
Please let me know if my approach is correct and hwo to achieve the same....
thanks in advance.