Bug 73692

Summary: crash in module-combine-sink adjust_rates
Product: PulseAudio Reporter: Daniel Albers <daniel>
Component: modulesAssignee: pulseaudio-bugs
Status: RESOLVED FIXED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: module-combine-sink: fix segfault
Stacktrace

Description Daniel Albers 2014-01-16 09:56:34 UTC
Created attachment 92212 [details] [review]
module-combine-sink: fix segfault

Pulseaudio often crashes here when pavucontrol is running.

Program received signal SIGSEGV, Segmentation fault.
adjust_rates (u=0x7cf7b0) at modules/module-combine-sink.c:219
219             uint32_t current_rate = o->sink_input->sample_spec.rate;

(gdb) p *o
$1 = {userdata = 0x7cf7b0, sink = 0x807880, sink_input = 0x0, ignore_state_change = false, inq = 0x804780, outq = 0x8047b0, inq_rtpoll_item_read = 0x0, inq_rtpoll_item_write = 0x0, outq_rtpoll_item_read = 0x0, outq_rtpoll_item_write = 0x0, memblockq = 0x8047e0, total_latency = 0, max_request = {value = 0}, requested_latency = {value = 0}, next = 0x0, prev = 0x0}

(gdb) p o->sink_input
$2 = (pa_sink_input *) 0x0

(gdb) list
214
215         base_rate = u->sink->sample_spec.rate;
216
217         PA_IDXSET_FOREACH(o, u->outputs, idx) {
218             uint32_t new_rate = base_rate;
219             uint32_t current_rate = o->sink_input->sample_spec.rate;
220
221             if (!o->sink_input || !PA_SINK_IS_OPENED(pa_sink_get_state(o->sink)))
222                 continue;
223


Putting the check in line 221f before the assignment in 219 seems to fix this.
Comment 1 Daniel Albers 2014-01-16 09:57:19 UTC
Created attachment 92213 [details]
Stacktrace
Comment 2 Tanu Kaskinen 2014-01-17 10:23:54 UTC
Thank you! I applied the patch with a small coding style change: all variables should be declared in the beginning of a block, so I moved the declaration of current_rate back to where it was.

http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=6b82c6122bc8e6907a15036a8f16b30f380ac459

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.