Segmentation fault in deployed app, not in qtcreator
-
Hello !
I am developing an app that uses a FTP connection at some point. I have recycled the example SimpleFTP using QScxml and it works well as long as I launch the program from QtCreator, in both debug and release version. When launching the deployed application, I have a crash with a segmentation fault. GDB backtracking indicates:```
Thread 1 "Qpl" received signal SIGSEGV, Segmentation fault.
0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) ()
from ./libQt6Scxml.so.6
`I have used ldd to check that no library is missing. I am stuck at how to go further in tracking the reason of this crash. Any suggestion more than welcome !
-
Hello !
I am developing an app that uses a FTP connection at some point. I have recycled the example SimpleFTP using QScxml and it works well as long as I launch the program from QtCreator, in both debug and release version. When launching the deployed application, I have a crash with a segmentation fault. GDB backtracking indicates:```
Thread 1 "Qpl" received signal SIGSEGV, Segmentation fault.
0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) ()
from ./libQt6Scxml.so.6
`I have used ldd to check that no library is missing. I am stuck at how to go further in tracking the reason of this crash. Any suggestion more than welcome !
@oliver_mpt
Let's start with: how did you "deploy" your application? Maybe it is picking up/not picking up stuff which is correct when run from the Creator environment but not outside?Also, when it crashes under gdb do you get a bit more of a stack trace than you show? I think the command in gdb is
bt
for backtrace, does it show more than just the one "frame" your output shows? And finally, are you using any threads in the code you have written? -
Hello !
I am developing an app that uses a FTP connection at some point. I have recycled the example SimpleFTP using QScxml and it works well as long as I launch the program from QtCreator, in both debug and release version. When launching the deployed application, I have a crash with a segmentation fault. GDB backtracking indicates:```
Thread 1 "Qpl" received signal SIGSEGV, Segmentation fault.
0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) ()
from ./libQt6Scxml.so.6
`I have used ldd to check that no library is missing. I am stuck at how to go further in tracking the reason of this crash. Any suggestion more than welcome !
@oliver_mpt ldd shows only linked libs and can not show missing plugins.
export QT_DEBUG_PLUGINS=1
or
use strace to see what is missing.
strace your_app -
Some more details, then:
I do the development on a linux machine, using a privileged account (with sudo access). Qt and QtCreator are installed for this account. For deployment test, I move the binaries (application + necessary libraries, including Qt ones, and config files) to another account on the SAME Machine, in a specific application directory. This account has minimal permissions.
The developed application is large and has always worked correctly, while deployed, until I added the FTP server.I have more trace from GDB, I had just limited to the problematic line, here is the remaining :
Thread 1 "Qpl" received signal SIGSEGV, Segmentation fault. 0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) () from ./libQt6Scxml.so.6 (gdb) bt #0 0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) () from ./libQt6Scxml.so.6 #1 0x00007ffff79e9734 in QScxmlStateMachinePrivate::processEvents() () from ./libQt6Scxml.so.6 #2 0x00007ffff5f8cf9c in QObject::event(QEvent*) () from ./libQt6Core.so.6 #3 0x00007ffff737eff2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from ./libQt6Widgets.so.6 #4 0x00007ffff5f3d9ea in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from ./libQt6Core.so.6 #5 0x00007ffff5f40c0d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from ./libQt6Core.so.6 #6 0x00007ffff61e8df3 in ?? () from ./libQt6Core.so.6 #7 0x00007ffff56f37a9 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #8 0x00007ffff56f3a38 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #9 0x00007ffff56f3acc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #10 0x00007ffff61e87ff in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from ./libQt6Core.so.6 #11 0x0000555555593397 in MainWindow::initJYSymphony ( this=this@entry=0x7fffffff9680) at ../../../Qt/6.5.2/gcc_64/include/QtCore/qflags.h:74 #12 0x00005555555aed28 in MainWindow::init_lockin ( --Type <RET> for more, q to quit, c to continue without paging--q
I will try to use strace tomorrow, when I'm back at office.
Thanks for the hints -
Some more details, then:
I do the development on a linux machine, using a privileged account (with sudo access). Qt and QtCreator are installed for this account. For deployment test, I move the binaries (application + necessary libraries, including Qt ones, and config files) to another account on the SAME Machine, in a specific application directory. This account has minimal permissions.
The developed application is large and has always worked correctly, while deployed, until I added the FTP server.I have more trace from GDB, I had just limited to the problematic line, here is the remaining :
Thread 1 "Qpl" received signal SIGSEGV, Segmentation fault. 0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) () from ./libQt6Scxml.so.6 (gdb) bt #0 0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) () from ./libQt6Scxml.so.6 #1 0x00007ffff79e9734 in QScxmlStateMachinePrivate::processEvents() () from ./libQt6Scxml.so.6 #2 0x00007ffff5f8cf9c in QObject::event(QEvent*) () from ./libQt6Core.so.6 #3 0x00007ffff737eff2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from ./libQt6Widgets.so.6 #4 0x00007ffff5f3d9ea in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from ./libQt6Core.so.6 #5 0x00007ffff5f40c0d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from ./libQt6Core.so.6 #6 0x00007ffff61e8df3 in ?? () from ./libQt6Core.so.6 #7 0x00007ffff56f37a9 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #8 0x00007ffff56f3a38 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #9 0x00007ffff56f3acc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #10 0x00007ffff61e87ff in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from ./libQt6Core.so.6 #11 0x0000555555593397 in MainWindow::initJYSymphony ( this=this@entry=0x7fffffff9680) at ../../../Qt/6.5.2/gcc_64/include/QtCore/qflags.h:74 #12 0x00005555555aed28 in MainWindow::init_lockin ( --Type <RET> for more, q to quit, c to continue without paging--q
I will try to use strace tomorrow, when I'm back at office.
Thanks for the hints@oliver_mpt I do not think it is even a good idea to run your app under sudo. It may ruin your computer.
-
Some more details, then:
I do the development on a linux machine, using a privileged account (with sudo access). Qt and QtCreator are installed for this account. For deployment test, I move the binaries (application + necessary libraries, including Qt ones, and config files) to another account on the SAME Machine, in a specific application directory. This account has minimal permissions.
The developed application is large and has always worked correctly, while deployed, until I added the FTP server.I have more trace from GDB, I had just limited to the problematic line, here is the remaining :
Thread 1 "Qpl" received signal SIGSEGV, Segmentation fault. 0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) () from ./libQt6Scxml.so.6 (gdb) bt #0 0x00007ffff79ddbdd in QScxmlStateMachinePrivate::setEvent(QScxmlEvent*) () from ./libQt6Scxml.so.6 #1 0x00007ffff79e9734 in QScxmlStateMachinePrivate::processEvents() () from ./libQt6Scxml.so.6 #2 0x00007ffff5f8cf9c in QObject::event(QEvent*) () from ./libQt6Core.so.6 #3 0x00007ffff737eff2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from ./libQt6Widgets.so.6 #4 0x00007ffff5f3d9ea in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from ./libQt6Core.so.6 #5 0x00007ffff5f40c0d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from ./libQt6Core.so.6 #6 0x00007ffff61e8df3 in ?? () from ./libQt6Core.so.6 #7 0x00007ffff56f37a9 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #8 0x00007ffff56f3a38 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #9 0x00007ffff56f3acc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #10 0x00007ffff61e87ff in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from ./libQt6Core.so.6 #11 0x0000555555593397 in MainWindow::initJYSymphony ( this=this@entry=0x7fffffff9680) at ../../../Qt/6.5.2/gcc_64/include/QtCore/qflags.h:74 #12 0x00005555555aed28 in MainWindow::init_lockin ( --Type <RET> for more, q to quit, c to continue without paging--q
I will try to use strace tomorrow, when I'm back at office.
Thanks for the hints@oliver_mpt said in Segmentation fault in deployed app, not in qtcreator:
using a privileged account (with sudo access). Qt and QtCreator are installed for this account
Oh dear! You should absolutely not do this, nor need it. And now you are saying you run as non-sudo outside of Creator and then have problems.
For deployment test, I move the binaries (application + necessary libraries, including Qt ones, and config files) to another account on the SAME Machine, in a specific application directory
This may not be sufficient, may be flawed, or may be missing something. You are really supposed to deploy "properly", e.g. using linuxdeployqt.
Next thing is to test your application outside of Creator but using sudo-type privileges like you say you use there rather than the minimal access. I'm not sure I think it will be a permission issue (rather than a deployment one) but you need to isolate/verify that.
I have recycled the example SimpleFTP using QScxml
Do you mean you have used https://doc.qt.io/qt-6/qtscxml-ftpclient-example.html ? You should confirm that works for you, I think.
I don't think someone here is going to know what is causing the seg fault just from what you describe and without some minimal example.
-
@oliver_mpt said in Segmentation fault in deployed app, not in qtcreator:
using a privileged account (with sudo access). Qt and QtCreator are installed for this account
Oh dear! You should absolutely not do this, nor need it. And now you are saying you run as non-sudo outside of Creator and then have problems.
For deployment test, I move the binaries (application + necessary libraries, including Qt ones, and config files) to another account on the SAME Machine, in a specific application directory
This may not be sufficient, may be flawed, or may be missing something. You are really supposed to deploy "properly", e.g. using linuxdeployqt.
Next thing is to test your application outside of Creator but using sudo-type privileges like you say you use there rather than the minimal access. I'm not sure I think it will be a permission issue (rather than a deployment one) but you need to isolate/verify that.
I have recycled the example SimpleFTP using QScxml
Do you mean you have used https://doc.qt.io/qt-6/qtscxml-ftpclient-example.html ? You should confirm that works for you, I think.
I don't think someone here is going to know what is causing the seg fault just from what you describe and without some minimal example.
-
@JonB Pretty messy now. All files and dirs used by the app and QtCreator are set to root:root. A clean-up is needed.
@JoeCFD said in Segmentation fault in deployed app, not in qtcreator:
All files and dirs used by the app and QtCreator are set to root:root. A clean-up is needed.
Also it's hard to tell, what the actual privileges were. So re-installing as user might be really the cleanest/fastest way to solve this :)
-
Hey,
I think I expressed myself very poorly. The program is never run as root or with root privileges. I was just stating that the development user belongs to the sudo group, while the test (deployment) user must not have any possibility to do so. In both cases, the app is ran with "normal" rights. Sorry for being so unclear.As already stated, the application, when deployed without FTP code included, works perfectly well (it's a huge app). The FTP module is used to connect to a Horiba-Jobin Yvon scientific camera, to exchange data. The code is a "fork" of the SCXML FTP client from qt doc, as linked by JonB. It is pretty similar, but works in a windowed application, instead of being a console app. When run from Qtcreator, all, including FTP transfers work fine.
-
Well !
JoeCFD gave me a very good hint. I tried running the app with QT_DEBUG_PLUGINS=1. I got the message :
qt.core.plugin.factoryloader: checking directory path "/home/oliver/Qpl/scxmldatamodel" "ecmascriptdatamodel" plugin not found
ldd did not reveal that, as JoeCFD mentionned ...
I'll try by adding the proper lib to my deployment package. -
Solved !
I had to add a subdirectory "scxmldatamodel" in the directory of the deployed app, with the library "libqscxmlecmascriptdatamodel.so" in it, then ldd indicated that the library "libQt6Qml.so.6" had to be added too. Then everything works perfectly.
Thanks to all for the suggestions and support. -