CESNET / UltraGrid

UltraGrid low-latency audio and video network transmission system
http://www.ultragrid.cz
Other
485 stars 55 forks source link

Switcher with multiple inputs, file playback crashes. #336

Closed sogorman closed 8 months ago

sogorman commented 9 months ago

When running the most recent nightly build UV crashes when switching to a file playback using the switcher.

Example:

/Applications/uv-qt.app/Contents/MacOS/uv -t switcher:excl_init  -t file:test.mp4 -t testcard -t testcard -c libavcodec:codec=H.265:bitrate=4m  --audio-codec MP3:sample_rate=48000:bitrate=320K --audio-capture-format channels=2 -f V:rs:200:240 -f A:rs:200:240 -m 1350 127.0.0.01 --param errors-fatal

When executing that command the file will start encoding without issue, you can switch to sources 2, and 3 a couple of times but when switching back to source 1 UV crashes.

[switcher] Switched to device 3 ().
[testcard] capture set to 1920x1080 @50.00i, codec UYVY, bpc 8, pattern: bars, audio off
Receiver of 0x78f30dd0 reports RTT=40283 usec, loss 0.00% (out of 1154 packets)
202 Accepted 
[switcher] Switched to device 2 ().
[testcard] capture set to 1920x1080 @50.00i, codec UYVY, bpc 8, pattern: bars, audio off
202 Accepted 
[switcher] Switched to device 1 (file:test.mp4).
[File cap.] Video format: 1920x1080 @29.97p, codec UYVY
Assertion failed: (node->cls == MODULE_CLASS_ROOT), function get_root_module, file module.c, line 193.
Backtrace:
0   uv-real                             0x00000001026ae0aa crash_signal_handler + 154
1   libsystem_platform.dylib            0x00007ff81c6a85ed _sigtramp + 29
2   libavutil.58.2.100.dylib            0x000000010d6e4f1b av_twofish_crypt + 3376
3   libsystem_c.dylib                   0x00007ff81c5a1b45 abort + 123
4   libsystem_c.dylib                   0x00007ff81c5a0e5e err + 0
5   uv-real                             0x0000000102d6e8c3 get_root_module.cold.2 + 35
6   uv-real                             0x00000001026f657e get_root_module + 46
7   uv-real                             0x00000001026b50db keycontrol_register_key + 187
8   uv-real                             0x00000001026b7f54 playback_register_keyboard_ctl + 132
9   uv-real                             0x00000001027dfc41 vidcap_file_init + 2833
10  uv-real                             0x0000000102740916 initialize_video_capture + 230
11  uv-real                             0x00000001027fac76 vidcap_switcher_grab + 358
12  uv-real                             0x0000000102740b26 vidcap_grab + 38
13  uv-real                             0x00000001028ad608 _ZL14capture_threadPv + 376
14  libsystem_pthread.dylib             0x00007ff81c67b1d3 _pthread_start + 125
15  libsystem_pthread.dylib             0x00007ff81c676bd3 thread_start + 15

UltraGrid has crashed (Abort trap).

Please send a bug report to address ultragrid-dev@cesnet.cz.
You may find some tips how to report bugs in file doc/REPORTING_BUGS.md distributed with UltraGrid
(or available online at https://github.com/CESNET/UltraGrid/blob/master/doc/REPORTING-BUGS.md).
zsh: abort      /Applications/uv-qt.app/Contents/MacOS/uv -t switcher:excl_init -t  -t  -t  -
(base) sogorman@Seans-MacBook-Pro Desktop % 
MartinPulec commented 9 months ago

Hi, I've finally managed to reproduce the issue, it is present only if :excl_init option is used.

I'll try to look at it. Anyways, do you have some particular reason, why do you use that option - is it to reset the file capture to the start of the file?

sogorman commented 9 months ago

Can confirm that :excl_init is the issue. Had it in place to mitigate Decklink missing input video on UG startup but let me play with this and see if I can work without the initialization call.

MartinPulec commented 9 months ago

Thanks for the info. Don't worry - if you need that option, I believe that I've just fixed the problem. Builds should be rebuilt in the continuous builds within a half of an hour.

sogorman commented 9 months ago

@MartinPulec Thanks. Using UltraGrid 1.8+ (master rev a2d3eb8 built Sep 15 2023 14:14:48) i can cofirm that launching UG with

/Applications/uv-qt.app/Contents/MacOS/uv -t switcher:excl_init -s embedded -t testcard -s embedded -t file:test1.mov:loop -s embedded -t decklink:connection=HDMI:mode=Hi59:codec=UYVY:device=0 -c libavcodec:codec=H.265:encoder=hevc_videotoolbox:bitrate=3.5M:subsampling=420:gop=20 --audio-codec MP3:sample_rate=48000:bitrate=256K --audio-capture-format channels=2 -f V:rs:150:200 -f A:rs:150:200 -m 1300 --param errors-fatal

No longer crashes when switching from switcher 1 (test pattern) to 2 (file:loop). That being said, if you switch a few times between 1 and 2 UG will eventually crash.

uv-real(7709,0x309ddb000) malloc: Incorrect checksum for freed object 0x7f806288a400: probably modified after being freed.
Corrupt value: 0x0
[lavc] Setting thread count to 1, type: (other)
uv-real(7709,0x309ddb000) malloc: *** set a breakpoint in malloc_error_break to debug
Backtrace:
0   uv-real                             0x000000010260d98a crash_signal_handler + 154
1   libsystem_platform.dylib            0x00007ff81c6a85ed _sigtramp + 29
2   ???                                 0x0000000000000000 0x0 + 0
3   libsystem_c.dylib                   0x00007ff81c5a1b45 abort + 123
4   libsystem_malloc.dylib              0x00007ff81c4b8752 malloc_vreport + 888
5   libsystem_malloc.dylib              0x00007ff81c4cda08 malloc_zone_error + 183
6   libsystem_malloc.dylib              0x00007ff81c4b17a1 small_free_list_remove_ptr_no_clear + 1017
7   libsystem_malloc.dylib              0x00007ff81c4ac9e6 small_malloc_from_free_list + 357
8   libsystem_malloc.dylib              0x00007ff81c4ac21b small_malloc_should_clear + 241
9   libsystem_malloc.dylib              0x00007ff81c4ac035 szone_malloc_should_clear + 109
10  libmp3lame.0.dylib                  0x000000011706b80e lame_encode_buffer_template + 191
11  libmp3lame.0.dylib                  0x000000011706bc17 lame_encode_buffer_int + 24
12  libavcodec.60.3.100.dylib           0x00000001148a8b5d av_jni_get_java_vm + 95164

UltraGrid has crashed (Abort trap).

Please send a bug report to address ultragrid-dev@cesnet.cz.
You may find some tips how to report bugs in file doc/REPORTING_BUGS.md distributed with UltraGrid
(or available online at https://github.com/CESNET/UltraGrid/blob/master/doc/REPORTING-BUGS.md).
MartinPulec commented 9 months ago

Had it in place to mitigate Decklink missing input video on UG startup but let me play with this and see if I can work without the initialization call.

I have to say that I don't understand how you mean "if I can work without the initialization call". Anyways, for this use-case, I believe that _exclinit is may be even counter-productive, because you are enforcing deinit the device switched from and initialization the device, which is switched to, with every switch. So you'll definitely don't mask some initialization delay.

MartinPulec commented 9 months ago

The audio problem - I think that I am able to reproduce. I'll create a separate issue when I find out more.

338

MartinPulec commented 8 months ago

assuming that this is no longer an issue because there is no further input

TheSashmo commented 7 months ago

I would say this should be re-opened, as I have the exact same issue of it crashing.

mpiatka commented 7 months ago

Is this the crash that you mentioned in #365? Or is it a separate issue? We will need more info in that case - ultragrid version, the command used, the terminal output. I tried on the recent continuous version and was unable to reproduce the issue.

MartinPulec commented 6 months ago

Hi @TheSashmo,

I would say this should be re-opened, as I have the exact same issue of it crashing.

the steps to reproduce this issue was actually (eg. with UG 1.8.4):

ffmpeg -t 1 -f lavfi -i testsrc in.mp4
uv -t switcher -t file:in.mp4 

If this is the case, feel free to reopen the issue, otherwise please open a new issue if needed.