AD-Vega / qarv

A Qt-based GUI and library interface for ethernet cameras using the Aravis library.
GNU General Public License v3.0
20 stars 14 forks source link

SegmentFault in QArvCameraId::QArvCameraId() #5

Closed mpthompson closed 6 years ago

mpthompson commented 6 years ago

When using a build of 'qarv' from the master branch and the libraries from the latest Aravis 0.5.12 release, within seconds after starting 'qarv' the application receives a segmentation fault with the following stack trace from gdb:

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_get_fake_camera_genicam_xml: assertion 'genicam_file != NULL' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_get_fake_camera_genicam_xml: assertion 'genicam_file != NULL' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_dom_document_new_from_memory: assertion 'buffer != NULL' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.793: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.794: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

(qarv:22647): Aravis-CRITICAL **: 14:51:15.794: arv_device_get_feature: assertion 'ARV_IS_GC (genicam)' failed

Thread 1 "qarv" received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
62  ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) where
#0  0x00007ffff5cd05a1 in __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
#1  0x00007ffff5bdf9ae in __GI___strdup (s=0x0) at strdup.c:41
#2  0x00007ffff698c8e0 in QArvCameraId::QArvCameraId(char const*, char const*, char const*) () at /home/mike/Development/aravis/qarv/qarv/build/libqarv-2.so.2
#3  0x00007ffff69914ca in QArvCamera::listCameras() () at /home/mike/Development/aravis/qarv/qarv/build/libqarv-2.so.2
#4  0x00007ffff6965b7c in QArv::QArvMainWindow::on_refreshCamerasButton_clicked(bool) () at /home/mike/Development/aravis/qarv/qarv/build/libqarv-2.so.2
#5  0x00007ffff6999a5e in QArv::QArvMainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) ()
    at /home/mike/Development/aravis/qarv/qarv/build/libqarv-2.so.2
#6  0x00007ffff6d8cf70 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#7  0x00007ffff6d977da in  () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#8  0x00007ffff6d92be3 in QObject::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#9  0x00007ffff72a503c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#10 0x00007ffff72abf76 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#11 0x00007ffff6d788ad in QCoreApplication::notifyInternal(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#12 0x00007ffff6dab6e0 in  () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#13 0x00007ffff6da8851 in  () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#14 0x00007ffff51fb287 in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007ffff51fb4c0 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007ffff51fb54c in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007ffff6da920e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#18 0x00007ffff7352666 in  () at /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#19 0x00007ffff6d7712f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#20 0x00007ffff6d77495 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#21 0x00007ffff6d7d459 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#22 0x00005555555569d8 in main ()

I haven't yet had time to figure out how to use cmake to create a debug build to investigate further, but I assume there is a problem with a string being passed into the QArvCameraId::QArvCameraId() object constructor. If I figure out the issue, I'll post back a fix.

mpthompson commented 6 years ago

For some reason the aravis library returns a "fake_" camera with vendor and model set to NULL. The following checks in QArvCameraId() constructor protects against segmentation violations in this instance and gets the application running.

QArvCameraId::QArvCameraId(const char* id_,
                           const char* vendor_,
                           const char* model_) {
  if (id_ == nullptr) id_ = "";
  if (vendor_ == nullptr) vendor_ = "";
  if (model_ == nullptr) model_ = "";
  id = strdup(id_);
  vendor = strdup(vendor_);
  model = strdup(model_);
}
exzombie commented 6 years ago

Thanks for noticing this! I just commited a fix for both contructors. I also made sure that cameras with null ids are not listed. That shouldn't happen, but then, neither should null vendor or model :/ . It definitely doesn't happen here (Aravis 0.5.12 on Arch Linux). If you ever find out why it happens to you, please let me know as it might be something that QArv should check.