Bug 1132 - Segfault fiddling with "conversion" "to logic via threshold"
Summary: Segfault fiddling with "conversion" "to logic via threshold"
Status: RESOLVED FIXED
Alias: None
Product: PulseView
Classification: Unclassified
Component: UI (show other bugs)
Version: unreleased development snapshot
Hardware: x86 Linux
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-05 15:23 CET by Chris West (Faux)
Modified: 2018-03-06 20:08 CET (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris West (Faux) 2018-03-05 15:23:25 CET
I can make PulseView segfault within a minute or so by fiddling with the "conversion thresholds" box for a Hantek 6022BE capture.

I'm not sure what actually causes the crash. Typing random values in (including invalid values) quickly? I suspect that there's some cross-thread race condition to do with re-computing the logic level graph, and re-submitting the logic level computation?

Note that, if you cause this crash, your X may hang up (as it thinks a menu is focused). Yay, X.

Here's one crash, I think I saw another inside Qt but I have lost it due to the aforementioned X rage. Note the "this=0x0":


[Thread 0x7fffd212e700 (LWP 23493) exited]
[New Thread 0x7fffd212e700 (LWP 23494)]
[New Thread 0x7fffd212e700 (LWP 23495)]
[Thread 0x7fffd212e700 (LWP 23494) exited]
[Thread 0x7fffd212e700 (LWP 23495) exited]
[New Thread 0x7fffd212e700 (LWP 23496)]

Thread 1 "pulseview" received signal SIGSEGV, Segmentation fault.
pv::data::Segment::segment_id (this=0x0) at /home/faux/code/sigrok/pulseview/pv/data/segment.cpp:96
96              return segment_id_;
(gdb) bt
#0  0x000055555561e370 in pv::data::Segment::segment_id() const (this=0x0)
    at /home/faux/code/sigrok/pulseview/pv/data/segment.cpp:96
#1  0x000055555567a088 in pv::views::ViewBase::on_samples_added(QObject*, unsigned long, unsigned long) (this=0x555555cc0fe0, segment=<optimised out>, start_sample=<optimised out>, end_sample=<optimised out>)
    at /home/faux/code/sigrok/pulseview/pv/views/viewbase.cpp:163
#2  0x000055555569fbb2 in pv::views::ViewBase::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimised out>, _id=<optimised out>, _a=<optimised out>, _c=<optimised out>)
    at /home/faux/code/sigrok/pulseview/build/pulseview_autogen/M3OR24FOW2/moc_viewbase.cpp:113
#3  0x00007ffff542fd72 in QObject::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff61bd753 in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#5  0x00007ffff617e82c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#6  0x00007ffff61860f4 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#7  0x00005555555da95b in Application::notify(QObject*, QEvent*) (this=<optimised out>, receiver=<optimised out>, event=<optimised out>) at /home/faux/code/sigrok/pulseview/pv/application.cpp:41
#8  0x00007ffff5400628 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007ffff5402d9d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff5459f13 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007ffff68bd117 in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#12 0x00007ffff68bd350 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#13 0x00007ffff68bd3dc in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007ffff545953f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007ffff53fe67a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007ffff54076c4 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00005555555d83e6 in main(int, char**) (argc=<optimised out>, argv=<optimised out>)
    at /home/faux/code/sigrok/pulseview/main.cpp:227
(gdb)

(gdb) info threads
  Id   Target Id         Frame
* 1    Thread 0x7ffff7fa5800 (LWP 23267) "pulseview" pv::data::Segment::segment_id (this=0x0)
    at /home/faux/code/sigrok/pulseview/pv/data/segment.cpp:96
  2    Thread 0x7fffe953a700 (LWP 23271) "QXcbEventReader" 0x00007ffff4557bf9 in __GI___poll (fds=0x7fffe9539ca8, nfds=1,
    timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  3    Thread 0x7fffe3fff700 (LWP 23272) "pulseview" 0x00007ffff4557bf9 in __GI___poll (fds=0x7fffe3ffee00, nfds=2, timeout=-1)
    at ../sysdeps/unix/sysv/linux/poll.c:29
  4    Thread 0x7fffe3435700 (LWP 23273) "QDBusConnection" 0x00007ffff4557bf9 in __GI___poll (fds=0x7fffdc004db0, nfds=2,
    timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  94   Thread 0x7fffd212e700 (LWP 23496) "pulseview" 0x000055555561583a in pv::data::LogicSegment::unpack_sample (
    this=this@entry=0x7fffad74bc50, ptr=0x7fffa59e6af5 '\001' <repeats 200 times>...)
    at /home/faux/code/sigrok/pulseview/pv/data/logicsegment.cpp:71
(gdb) thread 94
[Switching to thread 94 (Thread 0x7fffd212e700 (LWP 23496))]
#0  0x000055555561583a in pv::data::LogicSegment::unpack_sample (this=this@entry=0x7fffad74bc50,
    ptr=0x7fffa59e6af5 '\001' <repeats 200 times>...) at /home/faux/code/sigrok/pulseview/pv/data/logicsegment.cpp:71
71              switch (unit_size_) {
(gdb) bt
#0  0x000055555561583a in pv::data::LogicSegment::unpack_sample(unsigned char const*) const (this=this@entry=0x7fffad74bc50, ptr=0x7fffa59e6af5 '\001' <repeats 200 times>...) at /home/faux/code/sigrok/pulseview/pv/data/logicsegment.cpp:71
#1  0x0000555555615b7c in pv::data::LogicSegment::append_payload_to_mipmap() (this=this@entry=0x7fffad74bc50)
    at /home/faux/code/sigrok/pulseview/pv/data/logicsegment.cpp:246
#2  0x0000555555615d14 in pv::data::LogicSegment::append_payload(void*, unsigned long) (this=0x7fffad74bc50, data=<optimised out>, data_size=<optimised out>) at /home/faux/code/sigrok/pulseview/pv/data/logicsegment.cpp:159
#3  0x0000555555619862 in pv::data::SignalBase::convert_single_segment(pv::data::AnalogSegment*, pv::data::LogicSegment*) (this=this@entry=0x7fffe4009610, asegment=asegment@entry=0x7fffd4006500, lsegment=lsegment@entry=0x7fffad74bc50)
    at /home/faux/code/sigrok/pulseview/pv/data/signalbase.cpp:484
#4  0x000055555561a7fe in pv::data::SignalBase::conversion_thread_proc() (this=0x7fffe4009610)
    at /home/faux/code/sigrok/pulseview/pv/data/signalbase.cpp:585
#5  0x00007ffff4ea8373 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff75606db in start_thread (arg=0x7fffd212e700) at pthread_create.c:463
#7  0x00007ffff456488f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)


I'm running HEAD libsigrok, libsigrokdecode, pulsview, as of ~yesterday. 

7b7ab1f5cb3607bf29885eeffcb2cb215b2c9e9f
Date:   Sat Feb 10 10:52:16 2018 +0100

I'm using an unholy system, a mix of pre-release Ubuntu 18.04 and Qt 5.9.4 dev packages, so it might be that. amd64. Optimised build. Quad-core + HT i7-3770k. 50M samples, 8MHz.
Comment 1 Chris West (Faux) 2018-03-05 15:32:33 CET
Right, more reliable crash.

Set the demo driver to 10MHz, 500M samples.
Click A0, select "to logic via threshold".
Type "1.1" into the "Conversion threshold(s)" box.
As quickly as possible, type V, return, V, return, backspace, return, backspace, return, etc.

Almost immediately segfaults.
Comment 2 Uwe Hermann 2018-03-06 20:08:06 CET
Fixed in 7f894d958eb5221161f0c6f2abbb57d43bb6aae7, thanks!