diff mbox series

[FFmpeg-devel] sbc: do not set sample format in parser

Message ID 55f514f1-3148-d5c3-22c1-31d233ce0f19@free.fr
State Accepted
Commit 29993b2947a99806cf41dd58853af510b0ce152c
Headers show
Series [FFmpeg-devel] sbc: do not set sample format in parser | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Marc Gonzalez Jan. 5, 2021, 3:57 p.m. UTC
From: Arnaud Vrac <avrac@freebox.fr>
Date: Tue, 5 Jan 2021 13:47:43 +0100

Commit bdd31feec934 changed the SBC decoder to only set the output
sample format on init, instead of setting it explicitly on each frame,
which is correct. But the SBC parser overrides the sample format to S16,
which triggers a crash when combining the parser and the decoder.

Fix the issue by not setting the sample format anymore in the parser,
which is wrong.
---
We've been seeing the following crash signature:

Crash reason:  SIGSEGV /0x00000000
Crash address: 0x0
0 	libavcodec.so.58 	sbc_decode_frame
1 	libavcodec.so.58 	decode_receive_frame_internal
2 	libavcodec.so.58 	avcodec_send_packet
3 	fbxbta2dp 		decoder_th_func
4 	libpthread.so.0 	start_thread
5 	libc.so.6 		thread_start

NB: call stack obtained via CFI, so not necessarily correct
---
 libavcodec/sbc_parser.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Marc Gonzalez Jan. 9, 2021, 5:52 p.m. UTC | #1
Hello ffmpeg devs,

Any comments on the patch below?

Regards.

On 05/01/2021 16:57, Marc Gonzalez wrote:

> From: Arnaud Vrac <avrac@freebox.fr>
> Date: Tue, 5 Jan 2021 13:47:43 +0100
> 
> Commit bdd31feec934 changed the SBC decoder to only set the output
> sample format on init, instead of setting it explicitly on each frame,
> which is correct. But the SBC parser overrides the sample format to S16,
> which triggers a crash when combining the parser and the decoder.
> 
> Fix the issue by not setting the sample format anymore in the parser,
> which is wrong.
> ---
> We've been seeing the following crash signature:
> 
> Crash reason:  SIGSEGV /0x00000000
> Crash address: 0x0
> 0 	libavcodec.so.58 	sbc_decode_frame
> 1 	libavcodec.so.58 	decode_receive_frame_internal
> 2 	libavcodec.so.58 	avcodec_send_packet
> 3 	fbxbta2dp 		decoder_th_func
> 4 	libpthread.so.0 	start_thread
> 5 	libc.so.6 		thread_start
> 
> NB: call stack obtained via CFI, so not necessarily correct
> ---
>  libavcodec/sbc_parser.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavcodec/sbc_parser.c b/libavcodec/sbc_parser.c
> index f56564147a..5549b1951c 100644
> --- a/libavcodec/sbc_parser.c
> +++ b/libavcodec/sbc_parser.c
> @@ -42,7 +42,6 @@ static int sbc_parse_header(AVCodecParserContext *s, AVCodecContext *avctx,
>  
>      if (data[0] == MSBC_SYNCWORD && data[1] == 0 && data[2] == 0) {
>          avctx->channels = 1;
> -        avctx->sample_fmt = AV_SAMPLE_FMT_S16;
>          avctx->sample_rate = 16000;
>          avctx->frame_size = 120;
>          s->duration = avctx->frame_size;
> @@ -66,7 +65,6 @@ static int sbc_parse_header(AVCodecParserContext *s, AVCodecContext *avctx,
>                   + (joint * subbands)) + 7) / 8;
>  
>      avctx->channels = channels;
> -    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
>      avctx->sample_rate = sample_rates[sr];
>      avctx->frame_size = subbands * blocks;
>      s->duration = avctx->frame_size;
James Almer Jan. 9, 2021, 6:26 p.m. UTC | #2
On 1/9/2021 2:52 PM, Marc Gonzalez wrote:
> Hello ffmpeg devs,
> 
> Any comments on the patch below?
> 
> Regards.

Applied, thanks.

> 
> On 05/01/2021 16:57, Marc Gonzalez wrote:
> 
>> From: Arnaud Vrac <avrac@freebox.fr>
>> Date: Tue, 5 Jan 2021 13:47:43 +0100
>>
>> Commit bdd31feec934 changed the SBC decoder to only set the output
>> sample format on init, instead of setting it explicitly on each frame,
>> which is correct. But the SBC parser overrides the sample format to S16,
>> which triggers a crash when combining the parser and the decoder.
>>
>> Fix the issue by not setting the sample format anymore in the parser,
>> which is wrong.
>> ---
>> We've been seeing the following crash signature:
>>
>> Crash reason:  SIGSEGV /0x00000000
>> Crash address: 0x0
>> 0 	libavcodec.so.58 	sbc_decode_frame
>> 1 	libavcodec.so.58 	decode_receive_frame_internal
>> 2 	libavcodec.so.58 	avcodec_send_packet
>> 3 	fbxbta2dp 		decoder_th_func
>> 4 	libpthread.so.0 	start_thread
>> 5 	libc.so.6 		thread_start
>>
>> NB: call stack obtained via CFI, so not necessarily correct
>> ---
>>   libavcodec/sbc_parser.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/libavcodec/sbc_parser.c b/libavcodec/sbc_parser.c
>> index f56564147a..5549b1951c 100644
>> --- a/libavcodec/sbc_parser.c
>> +++ b/libavcodec/sbc_parser.c
>> @@ -42,7 +42,6 @@ static int sbc_parse_header(AVCodecParserContext *s, AVCodecContext *avctx,
>>   
>>       if (data[0] == MSBC_SYNCWORD && data[1] == 0 && data[2] == 0) {
>>           avctx->channels = 1;
>> -        avctx->sample_fmt = AV_SAMPLE_FMT_S16;
>>           avctx->sample_rate = 16000;
>>           avctx->frame_size = 120;
>>           s->duration = avctx->frame_size;
>> @@ -66,7 +65,6 @@ static int sbc_parse_header(AVCodecParserContext *s, AVCodecContext *avctx,
>>                    + (joint * subbands)) + 7) / 8;
>>   
>>       avctx->channels = channels;
>> -    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
>>       avctx->sample_rate = sample_rates[sr];
>>       avctx->frame_size = subbands * blocks;
>>       s->duration = avctx->frame_size;
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/libavcodec/sbc_parser.c b/libavcodec/sbc_parser.c
index f56564147a..5549b1951c 100644
--- a/libavcodec/sbc_parser.c
+++ b/libavcodec/sbc_parser.c
@@ -42,7 +42,6 @@  static int sbc_parse_header(AVCodecParserContext *s, AVCodecContext *avctx,
 
     if (data[0] == MSBC_SYNCWORD && data[1] == 0 && data[2] == 0) {
         avctx->channels = 1;
-        avctx->sample_fmt = AV_SAMPLE_FMT_S16;
         avctx->sample_rate = 16000;
         avctx->frame_size = 120;
         s->duration = avctx->frame_size;
@@ -66,7 +65,6 @@  static int sbc_parse_header(AVCodecParserContext *s, AVCodecContext *avctx,
                  + (joint * subbands)) + 7) / 8;
 
     avctx->channels = channels;
-    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
     avctx->sample_rate = sample_rates[sr];
     avctx->frame_size = subbands * blocks;
     s->duration = avctx->frame_size;