Bug 4 - Calling sr_session_stop from a different thread causes a segfault with the demo driver
Summary: Calling sr_session_stop from a different thread causes a segfault with the de...
Status: RESOLVED FIXED
Alias: None
Product: libsigrok
Classification: Unclassified
Component: Other (show other bugs)
Version: unreleased development snapshot
Hardware: x86 Linux
: High normal
Target Milestone: ---
Assignee: mrnuke
URL:
Keywords:
: 6 (view as bug list)
Depends on:
Blocks: 45
  Show dependency treegraph
 
Reported: 2012-12-17 18:10 CET by mrnuke
Modified: 2013-04-15 00:46 CEST (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mrnuke 2012-12-17 18:10:29 CET
With the sigrok session running in a worker thread, if sr_session_stop is called from the main thread, it shuts down the pollfds used by the hardware drivers, without ensuring that the sigrok event loop is no longer using those pollfds.

On the demo driver, this involves shutting down the GIOChannels, causing a segfault when the sigrok event loop tries to use them. Usu PulseView with the demo driver to test.

This isn't a problem with just the demo driver; any driver's resources may be freed by sr_session_stop concurrently with the sigrok session running.

st_session_stop should work with the event loop in  athread-safe manner.
Comment 1 mrnuke 2012-12-17 19:41:35 CET
*** Bug 6 has been marked as a duplicate of this bug. ***
Comment 2 mrnuke 2013-01-31 15:28:17 CET
This just became a blocker for the PulseView release.
Comment 4 mrnuke 2013-02-02 17:29:22 CET
The above patchset has two independent changes that both need to be applied to solve this bug:

1) Fix the problem I mentioned on IRC about the use of cb_data in the demo driver.

2) Make sr_session_stop() thread-safe.

Applying only one of the above will not solve the problem.