Bug 1150

Summary: Enabling boost::stacktrace corrupts srd session ID
Product: PulseView Reporter: Soeren Apel <soeren>
Component: OtherAssignee: Nobody <nobody>
Status: RESOLVED FIXED    
Severity: normal CC: uwe, wsa
Priority: Normal    
Version: unreleased development snapshot   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 1209    
Attachments: Patch to enable stacktrace completely

Description Soeren Apel 2018-04-05 22:29:05 CEST
When enabling boost::stacktrace on linux via -DENABLE_STACKTRACE=y, running a PD and closing PV results in a segfault:

--- stop_srd_session() called for 0xadc005b8 with session ID -1379921704
srd: Invalid session.
*** Error in `build/bin/pulseview': free(): invalid pointer: 0x0a5bfa48 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6d3ef)[0xb609a3ef]
/lib/libc.so.6(+0x74df4)[0xb60a1df4]
/lib/libc.so.6(+0x755ce)[0xb60a25ce]
/usr/lib/libglib-2.0.so.0(g_free+0x1f)[0xb743785c]
/usr/lib/libglib-2.0.so.0(g_slist_foreach+0x24)[0xb744f2ef]
/usr/lib/libglib-2.0.so.0(g_slist_free_full+0x2c)[0xb744f328]
/home/abraxa/repositories/sigrok/build/lib/libsigrokdecode.so.4(srd_session_destroy+0x41)[0xb74ffd71]
build/bin/pulseview(_ZN2pv4data12DecodeSignal16stop_srd_sessionEv+0x125)[0x83b0095]
build/bin/pulseview(_ZN2pv4data12DecodeSignal12reset_decodeEv+0x10e)[0x83adb9e]
build/bin/pulseview(_ZN2pv4data12DecodeSignalD1Ev+0x39)[0x83ad8c9]
build/bin/pulseview(_ZN9__gnu_cxx13new_allocatorIN2pv4data12DecodeSignalEE7destroyIS3_EEvPT_+0x2e)[0x826b57e]

Without boost::stacktrace, the session ID for the PD is always 1 and there's no issue when closing PV. With it, the session ID is consistently -1379921704 (at least on my machine), causing the error above.
Comment 1 Wolfram Sang 2020-04-15 01:11:00 CEST
Can't reproduce with today's build (1db57c03). I loaded the SR-file 'st_m24c02_powerup_and_reset.sr' from the dumps-repo and attached the I2C decoder to it, then closed PulseView -> no crash. Stacktraces are enabled ('Stack trace file is "/tmp/pv_stacktrace.dmp"'). Anything else I could try?
Comment 2 Soeren Apel 2020-04-15 08:25:35 CEST
Thanks for revisiting this bug but I don't think boost::stacktrace is enabled in any of the public builds at the moment because boost::stacktrace can't resolve the symbol names, which needs solving before we can roll out this feature.

It's enabled by cmake -DENABLE_STACKTRACE.
Comment 3 Wolfram Sang 2020-04-18 00:19:20 CEST
Created attachment 622 [details]
Patch to enable stacktrace completely

I enabled stacktrace with the attached patch (which is under discussion on the mailing list), but I still can't reproduce the above error. I took a larger file from the dumps repo and closed pv when the decoder was still decoding, but all went fine for me.
Comment 4 Uwe Hermann 2020-05-02 23:51:39 CEST
Merged in b409dfdc01ed36b54f5b8a70b3738146a26bf37e, thanks!

I can confirm that it builds fine with cmake 3.16.3 and Boost 1.71 on Debian (which does ship a libbacktrace).

No segfaults or corrupted session IDs in a few quick tests for me, either.