ros-industrial / ros_qtc_plugin

ROS Qt Creator Plug-in (https://ros-qtc-plugin.readthedocs.io)
396 stars 213 forks source link

Segmentation Fault #496

Closed collinthornton closed 5 months ago

collinthornton commented 5 months ago

QtCreator seg faults when opening a ROS project workspace file. It opens non-ROS projects without a problem.

Environment:

christian-rauch commented 5 months ago

Can you provide details on how you installed Qt Creator and the plugin? Can you provide a backtrace?

I just released version 13 and I can open my workspaces without issues. However, I have seen sporadic crashes of older Qt Creator versions also on non-ROS workspaces.

collinthornton commented 5 months ago

Qt Creator was installed via the online installer. The plugin was installed using the commands located here in the ReadMe.

This only appears to occur in specific directories. I can create a project in ~/Desktop without a problem, though the application seg faults when attempting to open in ~/projects/proj_wkspc.

Edit: This only occurs when opening ROS work spaces.

I'm happy to provide a backtrace, though I have never done so with an installed application (ie, not built from source). What's the most effective way to get the backtrace?

Edit: Here's the full output of running the application:

Warning: Ignoring WAYLAND_DISPLAY on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Failed to initialize instances shared memory:  "QSharedMemory::handle: doesn't exist"
Segmentation fault (core dumped)
IliasNanyageev commented 5 months ago

Probably, I found reason of seg faults. I caught seg fault in this line when read line of enviroment variable with empty value.

For example:

ROSLISP_PACKAGE_DIRECTORIES=

In this case

env_kv.size()==1.

Quick fix for me was remove parameter "Qt::SkipEmptyParts" in calling method "split" here since I don’t know whether it is necessary to process environment variables with empty values and insert them into env

christian-rauch commented 5 months ago

I added documentation on how to debug the plugin with gdb: https://github.com/ros-industrial/ros_qtc_plugin/pull/498. This should help to at least generate a backtrace. For more detailed debugging, I recommend compiling and debugging the plugin itself in Qt Creator.

@IliasNanyageev Can you provide a backtrace and more information with this, or even better fix the issue and send a PR?

christian-rauch commented 5 months ago

I can reproduce a crash via

ROSLISP_PACKAGE_DIRECTORIES= gdb --ex=r --args ~/Downloads/qtc-sdk/Tools/QtCreator/bin/qtcreator -pluginpath build/lib/qtcreator/plugins/

and get the following backtrace:

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737309825472) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737309825472) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737309825472, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff5642476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff56287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff5eb793c in  () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#6  0x00007ffff5eeda15 in  () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#7  0x00007ffff5eb8548 in qErrnoWarning(char const*, ...) () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#8  0x00007ffff5eb7900 in qBadAlloc() () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#9  0x00007fffa3e73468 in QList<QString>::at(long long) const (this=0x7fffffffc230, i=1) at ~/Downloads/qtc-sdk/6.6.0/gcc_64/include/QtCore/qlist.h:431
#10 0x00007fffa3e71a53 in QList<QString>::operator[](long long) const (this=0x7fffffffc230, i=1) at ~/Downloads/qtc-sdk/6.6.0/gcc_64/include/QtCore/qlist.h:440
#11 0x00007fffa3e661d4 in ROSProjectManager::Internal::ROSUtils::sourceWorkspaceHelper(QProcess*, QString const&) (process=0x7fffffffc990, path=...)
    at ~/Development/ros_qtc_plugin/src/project_manager/ros_utils.cpp:336
#12 0x00007fffa3e63217 in ROSProjectManager::Internal::ROSUtils::sourceROS(QProcess*, Utils::FilePath const&) (process=0x7fffffffc990, rosDistribution=...)
    at ~/Development/ros_qtc_plugin/src/project_manager/ros_utils.cpp:64
#13 0x00007fffa3e646ca in ROSProjectManager::Internal::ROSUtils::initializeWorkspace(QProcess*, ROSProjectManager::Internal::ROSUtils::WorkspaceInfo const&) (process=0x7fffffffc990, workspaceInfo=...)
    at ~/Development/ros_qtc_plugin/src/project_manager/ros_utils.cpp:176
#14 0x00007fffa3e63318 in ROSProjectManager::Internal::ROSUtils::sourceWorkspace(QProcess*, ROSProjectManager::Internal::ROSUtils::WorkspaceInfo const&) (process=0x7fffffffc990, workspaceInfo=...)
    at ~/Development/ros_qtc_plugin/src/project_manager/ros_utils.cpp:70
#15 0x00007fffa3e6f4bc in ROSProjectManager::Internal::ROSUtils::getWorkspaceEnvironment(ROSProjectManager::Internal::ROSUtils::WorkspaceInfo const&, Utils::Environment const&)
    (workspaceInfo=..., current_environment=...) at ~/Development/ros_qtc_plugin/src/project_manager/ros_utils.cpp:1217
#16 0x00007fffa3e12311 in ROSProjectManager::Internal::ROSProject::updateEnvironment() (this=0x26cb860) at ~/Development/ros_qtc_plugin/src/project_manager/ros_project.cpp:333
#17 0x00007fffa3e1559e in ROSProjectManager::Internal::ROSProject::updateCppCodeModel() (this=0x26cb860) at ~/Development/ros_qtc_plugin/src/project_manager/ros_project.cpp:560
#18 0x00007fffa3e29946 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (ROSProjectManager::Internal::ROSProject::*)()>::call(void (ROSProjectManager::Internal::ROSProject::*)(), ROSProjectManager::Internal::ROSProject*, void**)
    (f=(void (ROSProjectManager::Internal::ROSProject::*)(class ROSProjectManager::Internal::ROSProject * const)) 0x7fffa3e152bc <ROSProjectManager::Internal::ROSProject::updateCppCodeModel()>, o=0x26cb860, arg=0x7fffffffd130) at ~/Downloads/qtc-sdk/6.6.0/gcc_64/include/QtCore/qobjectdefs_impl.h:145
#19 0x00007fffa3e262ca in QtPrivate::FunctionPointer<void (ROSProjectManager::Internal::ROSProject::*)()>::call<QtPrivate::List<>, void>(void (ROSProjectManager::Internal::ROSProject::*)(), ROSProjectManager::Internal::ROSProject*, void**)
    (f=(void (ROSProjectManager::Internal::ROSProject::*)(class ROSProjectManager::Internal::ROSProject * const)) 0x7fffa3e152bc <ROSProjectManager::Internal::ROSProject::updateCppCodeModel()>, o=0x26cb860, arg=0x7fffffffd130) at ~/Downloads/qtc-sdk/6.6.0/gcc_64/include/QtCore/qobjectdefs_impl.h:182
#20 0x00007fffa3e22edf in QtPrivate::QCallableObject<void (ROSProjectManager::Internal::ROSProject::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*)
    (which=1, this_=0x3f61300, r=0x26cb860, a=0x7fffffffd130, ret=0x0) at ~/Downloads/qtc-sdk/6.6.0/gcc_64/include/QtCore/qobjectdefs_impl.h:520
#21 0x00007ffff5fb9c92 in  () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#22 0x00007ffff610107d in QFutureWatcherBase::event(QEvent*) () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#23 0x00007ffff7380ef2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Widgets.so.6
#24 0x00007ffff5f5d34a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#25 0x00007ffff5f608d5 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#26 0x00007ffff6204333 in  () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#27 0x00007ffff4f1bd3b in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007ffff4f71258 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007ffff4f193e3 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007ffff6203cca in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#31 0x00007ffff5f68cd3 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#32 0x00007ffff5f6579e in QCoreApplication::exec() () at ~/Downloads/qtc-sdk/Tools/QtCreator/bin/../lib/Qt/lib/libQt6Core.so.6
#33 0x000000000040e987 in  ()
#34 0x00007ffff5629d90 in __libc_start_call_main (main=main@entry=0x40b310, argc=argc@entry=3, argv=argv@entry=0x7fffffffdce8) at ../sysdeps/nptl/libc_start_call_main.h:58
#35 0x00007ffff5629e40 in __libc_start_main_impl (main=0x40b310, argc=3, argv=0x7fffffffdce8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdcd8)
    at ../csu/libc-start.c:392
christian-rauch commented 5 months ago

The problem is the Qt::SkipEmptyParts. That should stay the default Qt::KeepEmptyParts to keep the empty value for VAR=.

christian-rauch commented 5 months ago

See https://github.com/ros-industrial/ros_qtc_plugin/pull/499 for a fix.

collinthornton commented 5 months ago

Confirming that the new release resolved the issue. Thanks!