Bug 1275 - Segfault on cleanup
Summary: Segfault on cleanup
Status: RESOLVED FIXED
Alias: None
Product: libsigrok
Classification: Unclassified
Component: Driver: scpi-pps (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-07 16:37 CEST by Martin Ling
Modified: 2020-06-24 23:51 CEST (History)
2 users (show)



Attachments
valgrind output (2.99 KB, text/plain)
2018-09-07 16:37 CEST, Martin Ling
Details
proposal for fix (2 bytes, patch)
2020-04-11 23:54 CEST, Wolfram Sang
Details
proposal for fix (1.26 KB, patch)
2020-04-11 23:57 CEST, Wolfram Sang
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Ling 2018-09-07 16:37:01 CEST
Created attachment 453 [details]
valgrind output

With a Rigol DP821A connected over USB, running "sigrok-cli -d scpi-pps" with either --scan or --show works, but results in a segmentation fault during shutdown.

From valgrind, looks like a null pointer dereference in the std_cleanup->dev_close path.
Comment 1 Martin Ling 2018-09-11 11:27:16 CEST
Just an additional note, this doesn't happen after sigrok-cli has run a capture, so it looks like the problem may arise with dev_close() being called when the device hadn't actually been open.
Comment 2 Wolfram Sang 2020-04-11 23:54:59 CEST
Created attachment 618 [details]
proposal for fix

Martin, I attached a patch (developed independently) which might fix your issue. Could you check?
Comment 3 Wolfram Sang 2020-04-11 23:57:26 CEST
Created attachment 619 [details]
proposal for fix

Hopefully now correctly uploaded...
Comment 4 Uwe Hermann 2020-06-24 23:51:37 CEST
Should be fixed in 9b093606545ec3963a03a3cfac61954c62e93e10, thanks!

I've tested a similar device, Rigol DP712. Before the patch I didn't get a segfault but rather an error:

  sr: scpi_serial: Error while sending SCPI command 'SYST:LOCAL': -1.

After the patch that error is gone indeed. It's relatively likely that this was the same issue as bug 1151 as well, yeah.