Rendering any SVG having <text> tag in a thread crashes Win32/64 application on exit
I'm using librsvg 2.52 from MSYS2 under Windows. But the issue is reproducible with older versions as well. Using this pseudo code crashes Win32 application on exit even if the simplest SVG having text tag is rendered in a thread. The issue is reproducible even if only one SVG file is rendered.
LoadLibrary('libcairo-2.dll')
LoadLibrary('librsvg-2-2.dll')
//begin <thread code>
handle = rsvg_handle_new_from_data(streamPointer, streamSize, null)
rsvg_handle_get_dimensions(handle, dim)
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dim.width, dim.height)
cairo_surface_set_user_data(surface, null, null, null)
newctx = cairo_create(surface);
cairo_set_source_rgba(newctx, 1, 1, 1, 0);
cairo_paint(newctx);
rsvg_handle_render_document(handle, newctx, viewport, null);
cairo_destroy(newctx);
rsvg_handle_free(handle);
cairo_surface_destroy(surface);
//end <thread code>
wait_thread_to_terminate
FreeLibrary('librsvg-2-2.dll')
FreeLibrary('libcairo-2.dll')
exit //<== crash
The application doesn't crash on exit if rsvg_handle_render_document
is commented out or if the SVG
doesn't contain text tag or if the entire code is run in the main GUI thread.
Very complex SVG files not having text tags could be succesfully loaded in a thread and the application doesn't crash on exit.
Any ideas if it is a librsvg issue or something in its dependencies?
P.S. Same on 64-bit application. This time there is a little info in the callstack upon the crash:
:000007FED95F8258 ; ???
:000007FEF1ED4BC1 ; C:\msys64\mingw64\bin\libwinpthread-1.dll
:000007FEF1ED4F92 ; C:\msys64\mingw64\bin\libwinpthread-1.dll
:00000000773F50A8 ; ntdll.dll
:00000000773E87A8 ; ntdll.dll
:00000000773F3F08 ; ntdll.dll
System.EndThread(???)
Probably when text is rendered, some thread(s) are not terminated?