Segmentation fault
-
Hi!
I have been struggling with a segmentation fault in one week now without any progress of the cause. I hope someone can give me any hints how to continue.Short: it's hard to 'reproduce' the fault, sometimes it take 10 minutes and sometimes 10 hours or more. I just start the application and wait until it crash. My application is built on Rpi Buster, Qt 5.15.2. There is a GUI with 2 extra threads reading sensor data and handling audio output on low level. I also use the QTextToSpeech in the main thread.
Simple flow:
sensor thread transmit data to -> main thread (update GUI, and some calculations) -> sound threadIs it GUI related, thread related, sound related (QTextToSpeech, QIODevice, QAudioOutput)?
Thanks for support!
Best Regards
OlleHere is the crash dump in GDB
Thread 1 "GuideMe" received signal SIGSEGV, Segmentation fault. 0x75cf8008 in QObject::event(QEvent*) () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 (gdb) where #0 0x75cf8008 in QObject::event(QEvent*) () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #1 0x768caa4c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/Qt/5.15.2/lib/libQt5Widgets.so.5 #2 0x768d1fa0 in QApplication::notify(QObject*, QEvent*) () from /opt/Qt/5.15.2/lib/libQt5Widgets.so.5 #3 0x768d1868 in QApplicationPrivate::sendSyntheticEnterLeave(QWidget*) () from /opt/Qt/5.15.2/lib/libQt5Widgets.so.5 #4 0x00000000 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) info frame Stack level 0, frame at 0x7e827c58: pc = 0x75cf8008 in QObject::event(QEvent*); saved pc = 0x768caa4c called by frame at 0x7e827c70 Arglist at 0x7e827b80, args: Locals at 0x7e827b80, Previous frame's sp is 0x7e827c58 Saved registers: r4 at 0x7e827c44, r5 at 0x7e827c48, r6 at 0x7e827c4c, r7 at 0x7e827c50, lr at 0x7e827c54 (gdb)
I have also tried to debug inside Qt Creator but I does not help me, see below images:
-
@ollax452
GUI + thread related would be high on my list :)In each of your pictures the only think which would give much clue is the stack trace pane, which you never show but a line of. If that contains anything interesting it may be useful.
sensor thread transmit data to -> main thread (update GUI, and some calculations) -> sound thread
Any chance of making some mistake as to who accesses what/where/when across threads? :)
-
@JonB said in Segmentation fault:
stack trace pan
Thanks for your response.
I can't get anything from the debugger, similar as the GDB output, Qt internal things deep down, can't go upwards to my code. For that I need to recompile whole Qt with -g flag.
I have looked on the signal/slots between the GUI and the threads and can't find any obious faults. I use Qt::DirectConnection from GUI to thread (I have no event loop and protect data with QMutex), and from thread to GUI I use Qt::QuedConnection with no mutex.
Any more hints to continue?
/Olle -
As always - reduce your code until the crash no longer occurs. Don't access gui elements from outside the main gui thread (which you're for sure doing here). Use a tool like e.g. valgrind or adress/thread sanitizer to see where you're doing things wrong.
-
I agree, but the program has a lot of functions and it will take very long time to remove code and recompile and run.
Here is a new output from the GDB, if someone can see a cause from it please respond:
(gdb) thread apply all where Thread 89 (Thread 0x6eeff340 (LWP 26654)): #0 futex_reltimed_wait_cancelable (private=0, reltime=0x6eefec38, expected=0, futex_word=0xba0d00) at ../sysdeps/unix/sysv/linux/futex-internal.h:142 #1 __pthread_cond_wait_common (abstime=0x6eefec98, mutex=0x2, cond=0xba0cd8) at pthread_cond_wait.c:533 #2 __pthread_cond_timedwait (cond=0xba0cd8, mutex=0x2, abstime=0x6eefec98) at pthread_cond_wait.c:667 #3 0x75aeec64 in QWaitCondition::wait(QMutex*, QDeadlineTimer) () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #4 0x75aebd3c in ?? () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #5 0x75ae81bc in ?? () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #6 0x75a06494 in start_thread (arg=0x6eeff340) at pthread_create.c:486 #7 0x75793568 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /lib/arm-linux-gnueabihf/libc.so.6 Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 16 (Thread 0x60615340 (LWP 8762)): #0 __GI___nanosleep (remaining=0x60614418, requested_time=0x60614418) at ../sysdeps/unix/sysv/linux/nanosleep.c:28 #1 __GI___nanosleep (requested_time=0x60614418, remaining=0x60614418) at ../sysdeps/unix/sysv/linux/nanosleep.c:25 #2 0x75d1b870 in ?? () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #3 0x001d30e0 in SerialThread::run() () #4 0x75ae81bc in ?? () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #5 0x75a06494 in start_thread (arg=0x60615340) at pthread_create.c:486 #6 0x75793568 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /lib/arm-linux-gnueabihf/libc.so.6 Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 13 (Thread 0x69217340 (LWP 8623)): #0 __GI___poll (timeout=-1, nfds=2, fds=0x6ef07d68) at ../sysdeps/unix/sysv/linux/poll.c:29 --Type <RET> for more, q to quit, c to continue without paging-- #1 __GI___poll (fds=0x6ef07d68, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:26 #2 0x7550aa28 in ?? () from /lib/arm-linux-gnueabihf/libpulse.so.0 Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 12 (Thread 0x6a523340 (LWP 8620)): #0 __GI___libc_read (nbytes=1, buf=0xd6da1f, fd=18) at ../sysdeps/unix/sysv/linux/read.c:26 #1 __GI___libc_read (fd=18, buf=0xd6da1f, nbytes=1) at ../sysdeps/unix/sysv/linux/read.c:24 #2 0x75726abc in _IO_new_file_underflow (fp=0xd6d9d8) at libioP.h:839 #3 0x75719860 in _IO_getdelim (lineptr=0x6a522cdc, n=0x6a522ce0, delimiter=10, fp=0xd6d9d8) at iogetdelim.c:73 #4 0x70c061e4 in ?? () from /lib/arm-linux-gnueabihf/libspeechd.so.2 Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 11 (Thread 0x6aeb5340 (LWP 8617)): #0 __GI___libc_read (nbytes=1, buf=0xd0bfb7, fd=16) at ../sysdeps/unix/sysv/linux/read.c:26 #1 __GI___libc_read (fd=16, buf=0xd0bfb7, nbytes=1) at ../sysdeps/unix/sysv/linux/read.c:24 #2 0x75726abc in _IO_new_file_underflow (fp=0xd0bf70) at libioP.h:839 #3 0x75719860 in _IO_getdelim (lineptr=0x6aeb4cdc, n=0x6aeb4ce0, delimiter=10, fp=0xd0bf70) at iogetdelim.c:73 #4 0x70c061e4 in ?? () from /lib/arm-linux-gnueabihf/libspeechd.so.2 Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 10 (Thread 0x6b6b6340 (LWP 8563)): #0 __GI___poll (timeout=-1, nfds=1, fds=0x6e40cdf0) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 __GI___poll (fds=0x6e40cdf0, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:26 #2 0x75412eb4 in ?? () from /lib/arm-linux-gnueabihf/libglib-2.0.so.0 --Type <RET> for more, q to quit, c to continue without paging-- Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 9 (Thread 0x6beb7340 (LWP 8562)): #0 0x75788dd0 in __GI_ppoll (fds=0x6beb6758, nfds=1, timeout=<optimized out>, sigmask=<optimized out>) at ../sysdeps/unix/sysv/linux/ppoll.c:39 #1 0x75d17a20 in qt_safe_poll(pollfd*, unsigned long, timespec const*) () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 Backtrace stopped: Cannot access memory at address 0x4e17fff8 Thread 8 (Thread 0x6e2ff340 (LWP 8554)): #0 __GI___poll (timeout=13, nfds=1, fds=0x6e409bd8) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 __GI___poll (fds=0x6e409bd8, nfds=1, timeout=13) at ../sysdeps/unix/sysv/linux/poll.c:26 #2 0x75412eb4 in ?? () from /lib/arm-linux-gnueabihf/libglib-2.0.so.0 Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 3 (Thread 0x719ff340 (LWP 8548)): #0 __GI___poll (timeout=-1, nfds=2, fds=0x7100df08) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 __GI___poll (fds=0x7100df08, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:26 #2 0x75412eb4 in ?? () from /lib/arm-linux-gnueabihf/libglib-2.0.so.0 Backtrace stopped: previous frame identical to this frame (corrupt stack?) Thread 2 (Thread 0x72356340 (LWP 8547)): #0 __GI___poll (timeout=-1, nfds=1, fds=0x72355c44) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 __GI___poll (fds=0x72355c44, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:26 #2 0x7319506c in ?? () from /lib/arm-linux-gnueabihf/libxcb.so.1 Backtrace stopped: previous frame identical to this frame (corrupt stack?) --Type <RET> for more, q to quit, c to continue without paging-- Thread 1 (Thread 0x72c64240 (LWP 8545)): #0 0x75cf5494 in ?? () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #1 0x75cedfd8 in QObject::event(QEvent*) () from /opt/Qt/5.15.2/lib/libQt5Core.so.5 #2 0x768c0a4c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/Qt/5.15.2/lib/libQt5Widgets.so.5 #3 0x768c7fa0 in QApplication::notify(QObject*, QEvent*) () from /opt/Qt/5.15.2/lib/libQt5Widgets.so.5 #4 0x768c7868 in QApplicationPrivate::sendSyntheticEnterLeave(QWidget*) () from /opt/Qt/5.15.2/lib/libQt5Widgets.so.5 #5 0x00000000 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?)