Opened 5 years ago

Closed 3 years ago

#5615 closed defect (fixed)

avformat_open_input on dead UDP source link hangs after interrupt_callback signaled exit

Reported by: Marlon Mirchevski Owned by:
Priority: important Component: avformat
Version: git-master Keywords: udp regression
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Udp source is not active.
After returning 1 from interrupt_callback (exit), avformat_open_input does not return.

Using Win32 dll from Zeranoe on W10 64bit, Microsoft compiler

2015-05-22 Working
https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-20160522-git-566be4f-win32-shared.7z

2015-05-25 Not working
https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-20160525-git-9591ca7-win32-shared.7z

How to reproduce:
GetTickCount used can be any time function returning miliseconds.

unsigned long TimePrev=0;
//callback
static int cb_open(void *ctx) 
{
 //timeout after 3 seconds
 if(GetTickCount() - TimePrev > 3000)
  {
   printf("---interrupt_cb: Exit\n");
   return 1;
  }
 return 0;
}


void main()
{
 avformat_network_init();
 AVFormatContext *pFmtCtx = avformat_alloc_context();
 pFmtCtx->interrupt_callback.callback = cb_open;
 pFmtCtx->interrupt_callback.opaque = 0;

 const char *url="udp://127.0.0.1:8000";
 printf("avformat_open_input %s\n", url);
 TimePrev=GetTickCount();
 int nRet=avformat_open_input(&pFmtCtx, url, NULL, NULL);
 //here never called

Change History (14)

comment:1 by superware, 5 years ago

Can a developer please check this (old) defect? it's very easy to reproduce... Thanks!

in reply to:  1 ; comment:2 by Carl Eugen Hoyos, 5 years ago

Replying to superware:

Can a developer please check this (old) defect?

it's very easy to reproduce...

How can the issue be reproduced?

comment:3 by Carl Eugen Hoyos, 5 years ago

Keywords: open callback hang removed

in reply to:  2 comment:4 by superware, 5 years ago

Replying to cehoyos:

How can the issue be reproduced?

Hi cehoyos,

Simply open a non-existing UDP stream, such as "udp://127.0.0.1:8000", and avformat_open_input will hang even if the interrupt_callback.callback returns 1 ("During blocking operations, callback is called with opaque as parameter. If the callback returns 1, the blocking operation will be aborted.").

Actually all the details and code are supplied by Marlon above.

Thank you in advance.

in reply to:  2 comment:5 by superware, 5 years ago

Replying to cehoyos:

How can the issue be reproduced?

Hi cehoyos, have you managed to reproduce the bug? Thanks!

comment:6 by superware, 5 years ago

Marlon, do you have any new information regarding this issue?

comment:7 by Carl Eugen Hoyos, 5 years ago

Keywords: regression added
Priority: normalimportant

Which change introduced the regression?

comment:8 by superware, 5 years ago

Thanks cehoyos.

Well, it seems Marlon found ffmpeg-20160522-git-566be4f-win32-shared.7z working but ffmpeg-20160525-git-9591ca7-win32-shared.7z not.

comment:9 by Carl Eugen Hoyos, 5 years ago

Which of the 19 commits between 566be4f and 9591ca7 caused the regression?

comment:10 by superware, 5 years ago

I'm not sure. Have you managed to reproduce?

comment:11 by Carl Eugen Hoyos, 5 years ago

How can the issue be reproduced?

comment:12 by superware, 5 years ago

Please see Marlon's code snippet in the description.

comment:13 by Marlon Mirchevski, 3 years ago

This issue is fixed in version 4.0.2 or earlier.

I have just tested 32 and 64-bit versions from Zeranoe builds:
https://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-4.0.2-win32-dev.zip
https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.0.2-win64-dev.zip
on Windows 7 and 10 and it's OK.
Thanks!

comment:14 by Marlon Mirchevski, 3 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.