[FFmpeg-user] Which function calls libvorbis.c::oggvorbis_encode_frame()?

Journeyer Jeonghum journeyerhum at gmail.com
Sun Feb 19 15:34:16 CET 2012


I've tested this with this double free code in the function
oggvorbis_encode_frame()

        void * p;
        p = av_malloc(100);
        av_free(p);
        av_free(p);

and from the trial of ffmpeg on some wav file I got the gdb backtrace below.
And finally I found that avcodec_encode_audio() from
/usr/local/lib/libavcodec.so.53 is it.

Thanks very much.

Best regards.

(gdb) bt
#0  0x00007ffff58473a5 in __GI_raise (sig=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff584ab0b in __GI_abort () at abort.c:92
#2  0x00007ffff587f113 in __libc_message (do_abort=2,
fmt=0x7ffff59700d8 "*** glibc detected *** %s: %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:189
#3  0x00007ffff5889a96 in malloc_printerr (action=3,
str=0x7ffff5970210 "double free or corruption (fasttop)",
    ptr=<optimized out>) at malloc.c:6283
#4  0x00007ffff588dd7c in __GI___libc_free (mem=<optimized out>) at
malloc.c:3738
#5  0x00007ffff6b62011 in ?? () from /usr/local/lib/libavcodec.so.53
#6  0x00007ffff6c94a87 in avcodec_encode_audio () from
/usr/local/lib/libavcodec.so.53
#7  0x0000000000409fb4 in ?? ()
#8  0x000000000040da33 in ?? ()
#9  0x0000000000404bcc in ?? ()
#10 0x00007ffff583230d in __libc_start_main (main=0x404af0, argc=14,
ubp_av=0x7fffffffe018, init=<optimized out>,
    fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe008) at libc-start.c:226
#11 0x0000000000404d81 in ?? ()
#12 0x00007fffffffe008 in ?? ()
#13 0x000000000000001c in ?? ()
#14 0x000000000000000e in ?? ()
#15 0x00007fffffffe393 in ?? ()
#16 0x00007fffffffe3a9 in ?? ()
#17 0x00007fffffffe3ac in ?? ()
#18 0x00007fffffffe3b9 in ?? ()
#19 0x00007fffffffe3bc in ?? ()
#20 0x00007fffffffe3bf in ?? ()
#21 0x00007fffffffe3c3 in ?? ()
#22 0x00007fffffffe3c9 in ?? ()




2012/2/19 James Darnley <james.darnley at gmail.com>:
> On 2012-02-19 14:26, Journeyer Jeonghum wrote:
>> When I try a command below,
>>
>> ffmpeg -i "winlogon.wav" -t 60 -ar 44100 -ab 128k -ac 2 -acodec
>> libvorbis winlogon.ogg
>>
>> I can see that oggvorbis_encode_frame() in libvorbis.c is executed!
>>
>> Now I want to know which function calls oggvorbis_encode_frame().
>>
>> The C source code level analysis about this call link is somewhat
>> difficult for me. This is related function pointer and yasm I guess.
>>
>> The structure below is the very end I can figure out...
>>
>> AVCodec ff_libvorbis_encoder = {
>>         .name           = "libvorbis",
>>         .type           = AVMEDIA_TYPE_AUDIO,
>>         .id             = CODEC_ID_VORBIS,
>>         .priv_data_size = sizeof(OggVorbisContext),
>>         .init           = oggvorbis_encode_init,
>>         .encode         = oggvorbis_encode_frame,
>>         .close          = oggvorbis_encode_close,
>>         .capabilities   = CODEC_CAP_DELAY,
>>         .sample_fmts    = (const enum
>> AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
>>         .long_name      = NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
>>         .priv_class     = &class,
>> };
>>
>> "ff_libvorbis_encoder" is maybe used via some macro functions so that
>> I can't find places that uses it...
>
> No function directly calls oggvorbis_encode_frame, as can be seen by
> searching for it.  The encoding is done by calling it through a function
> pointer, which is what is setup by using the AVCodec structure.
>
> An application will call the the "encode frame" function of libavcodec
> and through some amount of indirection the computer will execute what is
> in oggvorbis_encode_frame.
>
> yasm has nothing to do with this.
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user



-- 
----------------------------------------
Journeyer Jeonghum Joh
journeyerhum at gmail.com
----------------------------------------


More information about the ffmpeg-user mailing list