Menu

#262 Double free when applying a LADSPA plugin with 2 input channels and 3 output channels

open
nobody
None
5
2024-11-30
2015-05-15
No

I have created a minimal plugin to reproduce the problem. The Makefile can be used to trigger the crash.

4 Attachments

Discussion

  • spider-mario

    spider-mario - 2015-05-17

    With this patch, ladspa plugins seem to work (at least with stereo sources, haven’t tried anything else) regardless of the number of output channels (1, 2, 3, and I suspect 4 or more work too).

    However, the patch shouldn’t be applied as is, as it completely breaks latency compensation (“FAIL ladspa: multi-channel effect drained asymmetrically!”). I’ll try and look into it more, I’m just reporting my progress.

     
  • spider-mario

    spider-mario - 2015-05-18

    This fixes asymmetric draining, but if latency compensation is enabled, then sox stops processing after three calls to sox_ladspa_flow if there are three output channels (still for a stereo source) and the latency reported by the plugin is greater than the buffer size used by sox. I have yet to figure out why exactly. (I suspect it may have to do with sox_ladspa_flow not producing any samples, but why would the issue depend on the number of output channels?)

     
  • spider-mario

    spider-mario - 2015-05-19

    Apparently, sox_ladspa_drain was broken, too, if the latency of the plugin was too high (sox_ladspa_drain would call sox_ladspa_flow one last time but then discard every sample past *osamp) or if the input was so short relative to the latency that the plugin still hadn’t output anything. Both of those issues are fixed by this new patch. (The latter is what the do-while loop is for.)

    The only issue that remains is that sox_ladspa_flow is called too few times when there are 3 output channels, latency compensation is enabled and the latency is really high, but since the current version of SoX crashes with 3 output channels regardless of latency or latency compensation, I don’t think that this patch introduces any regression.

     
  • spider-mario

    spider-mario - 2015-05-19

    I have finally fixed the remaining issue by:

    1. allowing run to be called with SampleCount = 0 (to at least get the latency)
    2. noticing that if the plugin does have in_latency, osamp does not have to be as big since obuf won’t be filled as much (outbuf will but it’s not a problem since enough memory is allocated for it).

    So, finally, the attached patch fixes LADSPA effects with more output channels than input channels (without breaking the other effects, of course) as well as draining for all LADSPA effects.

     

Log in to post a comment.

MongoDB Logo MongoDB