g_app_info_launch_default_for_uri() can lock up an application
@pgriffis
Submitted by Patrick Griffis Link to original bug (#795227)
Description
This situation specifically is very easily reproduced in Flatpak.
g_app_info_launch_default_for_uri() will try to run launch_default_for_uri() before anything else which leads to g_file_query_default_handler() being ran which leads to calling GVFS over dbus synchronously which locks up the application.
The URL specifically was https://mega.nz/#!MAAUnChK!-I5LcrBq3rbhrhrwbhuhkBrjpLq2H8MEc6Jp79ITV0k
and this can be reproduced with:
flatpak run --talk-name='org.gtk.vfs.*' --share=network --command=python3 org.gnome.Platform//3.28 -c 'from gi.repository import Gio; Gio.AppInfo.launch_default_for_uri("https://mega.nz/#!MAAUnChK!-I5LcrBq3rbhrhrwbhuhkBrjpLq2H8MEc6Jp79ITV0k")'
I suspect this never happens outside of Flatpak because the user always has an http handler but inside the Flatpak it doesn't.
It is worth noting that the async variant g_app_info_launch_default_for_uri_async() also calls this function and blocks forever in the main thread.
So ideally two things probably should be done:
- An async version of launch_default_for_uri() needs to be made for g_app_info_launch_default_for_uri_async()
- The sync version has some reasonable timeout