Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 931492 - media-video/vlc: crash when using SVG without fontconfig
Summary: media-video/vlc: crash when using SVG without fontconfig
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-07 13:04 UTC by Emanuel Komínek
Modified: 2024-05-08 18:02 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Emanuel Komínek 2024-05-07 13:04:26 UTC
When VLC is build with following options "-fontconfig svg", it crashes when displaying formatted subtitle line (in my case, it was italic text in SRT subtitles in form <i>blah blah</i>).

It fails in not very friendly way:
segfault at 0 ip 00007fa55e0c8272 sp 00007fa50fffd510 error 4 in libvlccore.so.9.0.1

With debug flag, it asserts in text/string.c#195

I don't know it it's fixable in upstream but I'd at least place "fontconfig" as default USE flag, or make svg dependent on it.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-07 23:03:29 UTC
Can you grab a backtrace please (https://wiki.gentoo.org/wiki/Debugging#Per-package)?
Comment 2 Emanuel Komínek 2024-05-08 11:31:34 UTC
>* thread #33, name = 'av:hevc:df0', stop reason = signal SIGABRT
>    frame #0: 0x00007ffff7e2fe9c libc.so.6`___lldb_unnamed_symbol3617 + 268
>    frame #1: 0x00007ffff7dde886 libc.so.6`raise + 22
>    frame #2: 0x00007ffff7dc68b7 libc.so.6`abort + 215
>    frame #3: 0x00007ffff7dc67db libc.so.6`___lldb_unnamed_symbol3097 + 15
>    frame #4: 0x00007ffff7dd6e96 libc.so.6`__assert_fail + 70
>    frame #5: 0x00007ffff7cd2ea7 libvlccore.so.9`vlc_xml_encode(str=0x0000000000000000) at strings.c:296:5
>  * frame #6: 0x00007fffcd6df4a6 libsvg_plugin.so`SegmentsToSVG(p_segment=0x00007fff87100280, i_height=46, pi_total_size=0x00007fffcd2b25cc) at svg.c:317:29
>    frame #7: 0x00007fffcd6df705 libsvg_plugin.so`RenderText(p_filter=0x00007fffa00e2e90, p_region_out=0x00007fff8c49b150, p_region_in=0x00007fff8c49b150, p_chroma_list=0x00007fffcd1ab5c8) at svg.c:373:19
>    frame #8: 0x00007ffff7cbd245 libvlccore.so.9`SpuRenderText(spu=0x00007fffa00e2180, rerender_text=0x00007fffcd2b26e3, region=0x00007fff8c49b150, chroma_list=0x00007fffcd1ab5c8, elapsed_time=0) at vout_subpictures.c:282:9
>    frame #9: 0x00007ffff7cbe585 libvlccore.so.9`SpuRenderRegion(spu=0x00007fffa00e2180, dst_ptr=0x00007fff8c418ac0, dst_area=0x00007fffcd2b2dc0, subpic=0x00007fff50000c60, region=0x00007fff8c49b150, scale_size=(w = 10000, h = 10000), chroma_list=0x00007fffcd1ab5c8, fmt=0x00007fffcd2b3d40, subtitle_area=0x00007fffcd2b2e90, subtitle_area_count=0, render_date=14354826212) at vout_subpictures.c:690:9
>    frame #10: 0x00007ffff7cbff15 libvlccore.so.9`SpuRenderSubpictures(spu=0x00007fffa00e2180, i_subpicture=2, pp_subpicture=0x00007fffcd2b38b0, chroma_list=0x00007fffcd1ab5c8, fmt_dst=0x00007fffcd2b3d40, fmt_src=0x00007fff8c0013f8, render_subtitle_date=14354826212, render_osd_date=14354735833) at vout_subpictures.c:1117:13
>    frame #11: 0x00007ffff7cc126a libvlccore.so.9`spu_Render(spu=0x00007fffa00e2180, chroma_list=0x00007fffcd1ab5c8, fmt_dst=0x00007fffcd2b3d40, fmt_src=0x00007fff8c0013f8, render_subtitle_date=14354826212, render_osd_date=14354735833, ignore_osd=false) at vout_subpictures.c:1610:28
>    frame #12: 0x00007ffff7cb6fe0 libvlccore.so.9`ThreadDisplayRenderPicture(vout=0x00007fffa00df610, is_forced=false) at video_output.c:1057:28
>    frame #13: 0x00007ffff7cb7859 libvlccore.so.9`ThreadDisplayPicture(vout=0x00007fffa00df610, deadline=0x00007fffcd2b3e90) at video_output.c:1250:15
>    frame #14: 0x00007ffff7cb90a6 libvlccore.so.9`Thread(object=0x00007fffa00df610) at video_output.c:1813:16
>    frame #15: 0x00007ffff7e2e101 libc.so.6`___lldb_unnamed_symbol3614 + 705
>    frame #16: 0x00007ffff7ea325c libc.so.6`___lldb_unnamed_symbol4008 + 7* thread #33, name = 'av:hevc:df0', stop reason = signal SIGABRT


I have following subtitle line:
> <i>and little families from Iowa</i>

It is parsed to following three segments:
> ""
> "and little families from Iowa"
> nullptr

As expected, VLC crashes on the third one.

Interestingly enough, the code in RenderText checks for "<svg" in the first segment, so I'd be expecting to see "<i>" there. So the question is whether the bug is in SVG renderer or subtitles parsing is incorrect.

It may be that using fontconfig, this issue is just hidden (I didn't check).
Comment 3 Emanuel Komínek 2024-05-08 18:02:46 UTC
Further debugging led me to ParseSubtitles() function which splits subtitle lines to segments. It seems it's quite normal not to set psz_text (except for first segment) for formatting tags. It's in line with the behavior I observe in crash callstack.

With that information, it just seems that SVG text renderer isn't mature enough in upstream and I can hardly recommend it.

I have come up with a patch that fixes the issue but I still believe that most people should compile VLC with fontconfig and that's still my proposal.

The patch probably belongs to upstream and formatting is ignored (AFAIK it's not implemented in SVG renderer): 
> --- a/modules/text_renderer/svg.c 2023-02-11 10:33:18.000000000 +0100
> +++ b/modules/text_renderer/svg.c 2024-05-08 19:46:10.187641898 +0200
> @@ -314,7 +314,7 @@
>      for( ; p_segment; p_segment = p_segment->p_next )
>      {
>          char *psz_prev = psz_result;
> -        char *psz_encoded = vlc_xml_encode( p_segment->psz_text );
> +        char *psz_encoded = vlc_xml_encode( p_segment->psz_text ? > p_segment->psz_text : "");
>          if( asprintf( &psz_result, "%s<tspan x='0' dy='%upx'>%s</tspan>\n",
>                                     (psz_prev) ? psz_prev : "",
>                                      i_height,