[vorbis-dev] VorbisFile library crashs.

Yuri Gulyaev yuri at at-soft.net
Sun Jan 5 20:47:15 PST 2003



Hello Conrad!

> From: Conrad Parker <conrad at vergenet.net>
> Date: Mon, 6 Jan 2003 13:31:51 +1100
> To: Yuri Gulyaev <yuri at at-soft.net>
> Cc: vorbis-dev at xiph.org, eduard at at-soft.net
> Subject: Re: [vorbis-dev] VorbisFile library crashs.
> 
> [cc'd back to vorbis-dev]
> 
> Hi Yuri,
> 
> building your program as a single .c file on Linux does not produce this
> error. I'd guess that the problem is not in VorbisFile.

Well, the problem might be in VorbisFile under Mac OS. BTW the Mac OS
classic SDK contains libraries that don't export any functions (probably
someone forgot to add the .EXP file to the project when compiling it) so I
downloaded the vorbis_nightly_cvs.tgz archive and compiled the libraries
myself.

> 
> Here it is as straight C code:
> 
> -----
> #include <stdio.h>
> #include <vorbis/vorbisfile.h>
> 
> int
> main (int argc, char ** argv)
> {
> FILE * inputFile;
> OggVorbis_File ovFile;
> int xxx;
> 
> if (argc < 3) {
> fprintf (stderr, "Usage: %s file1.ogg file2.ogg\n", argv[0]);
> exit (1);
> }
> 
> inputFile = fopen (argv[1], "r");

You should use "rb". I can't say about UNIX but in Windows and maybe also
Mac OS it's in text mode by default.

> 
> xxx = ov_open (inputFile, &ovFile, NULL, 0);
> xxx = ov_clear (&ovFile);
> 
> inputFile = fopen (argv[2], "r");
> 
> xxx = ov_open (inputFile, &ovFile, NULL, 0);
> xxx = ov_clear (&ovFile);
> 
> return 0;
> }
> 
> -----
> 
> To build in the Terminal:
> 
> gcc ovopen.c -o ovopen -lvorbisfile -lvorbis -logg -lm
> 
> -----
> 
> I'm not running OS X atm so I can't test this there, perhaps you should
> check your project settings. Also I hope you're actually checking the
> return values from ov_open in the real project ;)

Sure I check in my project what it returns. This xxx is just to see in the
debugger what it returns, of course _if_ it returns. :)
I think all project settings are correct. If you have an idea of what
settings may cause the problem please let me know.

I actually have not yet reached the poing when I would need to do this on
Mac OS X so now I am dealing with only Mac OS 9. Maybe someone of you guys
should try to run my project on Mac OS 9.

The files I was trying to open were Epoq-Lepidoptera.ogg and
Hydrate-Kenny_Beltrey.ogg. I downloaded them from your web site. I was
actually able to play them today with the player I develop so they don't
appear to be corrupt. However my application can only open one file, then it
crashs on the 2nd one. Actually it crashs a lot even while playing the 1st
one. I develop an Ogg Vorbis playback plugin for MACAST player (see
www.at-soft.net). So this is going to be a one more player that can play OGG
files. So I think you guys should be interested in this... ;)

Here is stack of function calls where exactly it crashs:

ov_open (the 2nd time I call this function)
ov_open_callbacks
_ov_open2
_open_seekable2
_bisect_forward_serialno (in _open_seekable2 this is the 2nd call to this
function, after the ELSE)
within _bisect_forward_serialno on this line:
vf->offsets=_ogg_malloc((vf->links+1)*sizeof(*vf->offsets));
__pool_alloc
allocate_from_fixed_pools

When I replaced ov_open with ov_test it crashed on the last call to ov_clear
on this line:
_ogg_free(vf->vi);

So it seems someone damages someone else's memory. So this bug may be
anywhere. It might have something to do with alignment of members of
structures on different platforms/compilers.

I tried doing this:

    #define _ogg_malloc( s ) ( (void *) ( (char *) malloc ( (s) + 512 ) +
256 ) )
    #define _ogg_calloc( n, s ) ( (void *) ( (char *) calloc ( 1, (n) * (s)
+ 512 ) + 256 ) )
    #define _ogg_realloc( p, s ) ( (void *) ( (char *) realloc ( (void *)
((char *) (p) - 256), (s) + 512 ) + 256 ) )
    #define _ogg_free( p ) free ( (void *) ((char *) (p) - 256) )

and this:

    #define _ogg_malloc( s ) ( (void *) NewPtr (s) )
    #define _ogg_calloc( n, s ) ( (void *) NewPtrClear ( (n) * (s) ) )
/*    #define _ogg_realloc( p, s )*/
    void * _ogg_realloc (void * p, size_t s);
    #define _ogg_free( p ) DisposePtr (p)
void * _ogg_realloc (void * p, size_t s)
{
    void * newp = _ogg_malloc (s);
    size_t olds = GetPtrSize (p);
    memcpy (newp, p, s < olds ? s : olds);
    _ogg_free (p);
    return newp;
}

but it did not help...

Thanks,

Yuri.

<p>> 
> Conrad.
> www.metadecks.org
> 
> On Sun, Jan 05, 2003 at 06:31:57PM -0500, Yuri Gulyaev wrote:
>> Sure Conrad. Here it is.
>> Just in case you cannot reproduse the bug you should probably download the
>> project and try to run it. The problem might be in project settings however
>> I don't think the settings cause the crash.
>> 
>> 
>> extern "C"
>> {
>> #include <vorbis/vorbisfile.h>
>> }
>> 
>> int main ()
>> {
>> // Change file name to the one that exists on your hard drive.
>> FILE * inputFile = ::fopen
>> ("Partition1:Users:yg:Desktop:Work:TestFiles:Ogg:Epoq-Lepidoptera.ogg",
>> "rb");
>> OggVorbis_File ovFile;
>> int xxx = ::ov_open (inputFile, & ovFile, NULL, 0);
>> xxx = ::ov_clear (& ovFile);
>> // You can open either the same or a different file, the result will be
>> the same.
>> inputFile = ::fopen
>> ("Partition1:Users:yg:Desktop:Work:TestFiles:Ogg:Hydrate-Kenny_Beltrey.ogg",
>> "rb");
>> // The next attempt to open file will crash with a message "Unmapped
>> memory exception".
>> xxx = ::ov_open (inputFile, & ovFile, NULL, 0);
>> xxx = ::ov_clear (& ovFile);
>> 
>> return 0;
>> }
>> 
>> 
>>> From: Conrad Parker <conrad at vergenet.net>
>>> Date: Mon, 6 Jan 2003 10:19:49 +1100
>>> To: Yuri Gulyaev <yuri at at-soft.net>
>>> Subject: Re: [vorbis-dev] VorbisFile library crashs.
>>> 
>>> Hi Yuri,
>>> 
>>> can you post just the .c file that exhibits the bug?
>>> 
>>> Conrad.
>>> 
>>> On Sun, Jan 05, 2003 at 05:47:10PM -0500, Yuri Gulyaev wrote:
>>>> Hello!
>>>> There is a problem with the VorbisFile library. It only works when I open
>>>> an
>>>> OGG file for
>>>> the 1st time. After I closed the file and try to open another one or the
>>>> same it crashs. It seems it applies to the use of either ov_open or ov_test
>>>> functions or their combination.
>>>> I wrote a test app that illustrates the bug. It crashs with a message
>>>> "Unmapped memory exception". It's available at
>>>> http://home.earthlink.net/~yurigulyaev/oggvorbisproject32.sit.hqx
>>>> My platform is Mac OS 9.2 and CodeWarrior 8.0. I got the same result with
>>>> CodeWarrior 7.0.
>>>>> From what I read on the net I see that this bug exists on other platforms
>>>> too.
>>>> BTW, I had to compile shared libs on my own because the OggVorbis SDK for
>>>> Mac OS
>>>> comes with shared libs that don't export any functions and thus unusable.
>>>> I have also submitted this bug through bugzilla.
>>>> SY,
>>>> Yuri.
>>>> 
>>>> --- >8 ----
>>>> List archives:  http://www.xiph.org/archives/
>>>> Ogg project homepage: http://www.xiph.org/ogg/
>>>> To unsubscribe from this list, send a message to
>>>> 'vorbis-dev-request at xiph.org'
>>>> containing only the word 'unsubscribe' in the body.  No subject is needed.
>>>> Unsubscribe messages sent to the list will be ignored/filtered.
>>> 
> 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis-dev mailing list