#775983 oggenc: Invalid memory access with low sampling rate

Package:
vorbis-tools
Source:
vorbis-tools
Description:
several Ogg Vorbis tools
Submitter:
Jakub Wilk
Date:
2015-10-08 21:45:06 UTC
Severity:
normal
#775983#3
Date:
2015-01-22 10:05:31 UTC
From:
To:
I tried to resample the input file to a very low rate, but oggenc
crashed:

$ oggenc --resample=500 test.wav
Opening with wav module: WAV file reader
Resampling input from 8000 Hz to 500 Hz
Encoding "test.wav" to
         "test.ogg"
at quality 3.00
BUG: Got zero samples from resampler: your file will be truncated. Please report this.
*** Error in `oggenc': double free or corruption (out): 0x094347b0 ***
Aborted

#775983#8
Date:
2015-09-24 21:15:47 UTC
From:
To:
[Jakub Wilk 2015-01-22]

This no longer happen with version 1.4.0-6 on my machine, at least.
Now I get an error instead:

  % oggenc --resample=500 test.wav
  Opening with wav module: WAV file reader
  Resampling input from 8000 Hz to 500 Hz
  Encoding "test.wav" to
           "test.ogg"
  at quality 3.00
  BUG: Got zero samples from resampler: your file will be truncated. Please report this.


  Done encoding file "test.ogg"

          File length:  0m 00.0s
          Elapsed time: 0m 00.0s
          Rate:         0.0000
          Average bitrate: inf kb/s

  %

Is there something special about the input file?  How was it created?

#775983#13
Date:
2015-09-24 23:30:17 UTC
From:
To:
Petter Reinholdtsen wrote:

No crash for me, either. But valgrind reports a whole bunch of invalid
memory access problems. Depending on the memory layout, they probably
lead to the crash.

Cheers,
Martin

#775983#16
Date:
2015-09-25 10:21:59 UTC
From:
To:
* Petter Reinholdtsen <pere@hungry.com>, 2015-09-24, 23:15:

Hmm, it still crashes for me.

No, nothing special about it.

It took an audio file that I've been using for IM notification for the
last decade, and converted it with oggdec to the Wave format. (I hope I
fully satisfied your curiosity. :-P)

#775983#23
Date:
2015-09-25 16:34:47 UTC
From:
To:
[Jakub Wilk]

Hm.  Can you run oggenc using valgrind (just install valgrind and add it
in front of the command), and let us know what the output is?  The
output will be more useful if the vorbis-tools-dbg package is installed
too.  This will provide more details about why and where it crashes, as
well as other problems in the code.

Right.  Was wondering if it was a special test case of some kind, with
some rare properties.

#775983#26
Date:
2015-09-25 20:58:21 UTC
From:
To:
* Petter Reinholdtsen <pere@hungry.com>, 2015-09-25, 18:34:

Valgrind log attached.

#775983#31
Date:
2015-09-27 08:59:18 UTC
From:
To:
I asked for comments on the #xiph IRC channel, and got these comments:

<mark4o> 500 Hz is a really low sample rate for audio
<OmniMancer> would anyone ever use 500Hz for actual Audio? or are they
  likely recoding some other signal?
<TD-Linux> I can't think of a use case. but it shouldn't crash
<OmniMancer> well yes, crashing is bad :/
<erikd> if vorbis can't handle really low sample rates it should
  validate its inputs and reject them
<mark4o> it's not vorbis itself it's the resampler
<erikd> its the resampler that crashing?
<mark4o> the code in oggenc that calls the resampler apparently
<mark4o> which looks like it was rewritten in opusenc, maybe it can be
  copied from there, not sure
<OmniMancer> I am glad that atleast in FLAC sample rate is just metadata
:)
<mark4o> it is in vorbis also, but oggenc has an option to resample it
  first; not sure why
<OmniMancer> vorbis is lossy and uses frequency space transforms though?
<mark4o> yes
<OmniMancer> so the sample rate could affect the result of coding?
<mark4o> I'm pretty sure it affects at least frame durations, but I'm
  not a vorbis expert.

Perhaps something to investigate?

#775983#36
Date:
2015-10-08 21:40:17 UTC
From:
To:
tags 775983 + confirmed
retitle 775983 oggenc: Invalid memory access with low sampling rate
thanks


The problem seems to be independent of oggenc's resampler. It can be observed with any input file having a low sampling rate, e.g.:

The cut-off frequency seems to be 512 Hz. Everything >= 512 Hz works, everything < 512 Hz exposes the invalid memory access.

To me it looks a little bit like libvorbis cannot encode audio with such a low sampling rate. But either it fails to refuse such inputs with a sanity check, or oggenc doesn't properly check the return codes. However, I've checked the oggenc encoder code and it seems to be pretty thorough about return code checking, both in generally and specifically regarding the calls to the functions "vorbis_encode_setup_managed" and "vorbis_encode_setup_managed", which is where the sampling rate is passed to libvorbis.

Looks like this needs some proper debugging...

Cheers,
Martin