Crash under get_renamed_component()
Moving this from a downstream bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1944675
When there's installed an old application, which has got renamed under Flatpak, it can cause a crash when the gnome-software is compiled with libxmlb 0.3.0+. There's a typo in the search string. It took me some time to reproduce it, a merge requests follows.
Thread 1 (Thread 0x7f79056a2640 (LWP 84500)):
#0 g_log_structured_array (log_level=<optimized out>, fields=0x7f79056a1290, n_fields=4) at ../glib/gmessages.c:556
__func__ = "g_log_structured_array"
#1 0x00007f791f36f1e9 in g_log_default_handler (log_domain=log_domain@entry=0x7f790c2040eb "XbSilo", log_level=log_level@entry=6, message=message@entry=0x7f78f88b9b40 "Invalid XPath query \342\200\230components[@origin=?/component/bundle[@type='flatpak'][text()=?]/..\342\200\231: predicate [@origin=? was unfinished, missing ']'", unused_data=unused_data@entry=0x0) at ../glib/gmessages.c:3236
fields = {{key = 0x7f791f3ca2e7 "GLIB_OLD_LOG_API", value = 0x7f791f3c8340, length = -1}, {key = 0x7f791f3ca228 "MESSAGE", value = 0x7f78f88b9b40, length = -1}, {key = 0x7f791f3ca23b "PRIORITY", value = 0x7f791f3c471d, length = -1}, {key = 0x7f791f3ca295 "GLIB_DOMAIN", value = 0x7f790c2040eb, length = -1}}
n_fields = <optimized out>
#2 0x00007f791f3705ba in g_logv (log_domain=0x7f790c2040eb "XbSilo", log_level=G_LOG_LEVEL_ERROR, format=<optimized out>, args=<optimized out>) at ../glib/gmessages.c:1382
domain = 0x0
data = 0x0
depth = <optimized out>
log_func = 0x7f791f36f130 <g_log_default_handler>
domain_fatal_mask = <optimized out>
masquerade_fatal = 0
test_level = 6
was_fatal = <optimized out>
was_recursion = <optimized out>
msg = 0x7f78f88b9b40 "Invalid XPath query \342\200\230components[@origin=?/component/bundle[@type='flatpak'][text()=?]/..\342\200\231: predicate [@origin=? was unfinished, missing ']'"
msg_alloc = 0x7f78f88b9b40 "Invalid XPath query \342\200\230components[@origin=?/component/bundle[@type='flatpak'][text()=?]/..\342\200\231: predicate [@origin=? was unfinished, missing ']'"
i = 2
#3 0x00007f791f3708a3 in g_log (log_domain=log_domain@entry=0x7f790c2040eb "XbSilo", log_level=log_level@entry=G_LOG_LEVEL_ERROR, format=format@entry=0x7f790c2057d8 "Invalid XPath query \342\200\230%s\342\200\231: %s") at ../glib/gmessages.c:1451
args = {{gp_offset = 40, fp_offset = 48, overflow_arg_area = 0x7f79056a14c0, reg_save_area = 0x7f79056a1400}}
#4 0x00007f790c2005e9 in xb_silo_lookup_query (self=self@entry=0x7f78fc00f1f0 [XbSilo], xpath=xpath@entry=0x7f790c1baa88 "components[@origin=?/component/bundle[@type='flatpak'][text()=?]/..") at ../src/xb-silo.c:1655
error_local = 0x55dbac1e3650
query = 0x0
priv = 0x7f78fc00f160
result = 0x0
#5 0x00007f790c1adce0 in get_renamed_component (silo=0x7f78fc00f1f0 [XbSilo], app=0x7f78fc0fa560 [GsApp], self=0x55dbabe3ecd0 [GsFlatpak]) at ../plugins/flatpak/gs-flatpak.c:2679
origin = 0x7f78f824f990 "flathub"
renamed_to = 0x7f78f81f63b0 "app/org.gabmus.gfeeds/x86_64/stable"
xpath = 0x0
context = {dummy0 = 0, dummy1 = 0, dummy2 = {dummy0 = 0, dummy1 = {0x0, 0x0}, dummy2 = 0, dummy3 = {0x0, 0x0}, dummy4 = 0, dummy5 = {0x0, 0x0}, dummy6 = 0, dummy7 = {0x0, 0x0}, dummy8 = {0x0, 0x0, 0x0}}, dummy3 = {0x0, 0x0, 0x0, 0x0, 0x0}}
remote_ref = 0x55dbac0319e0
component = 0x0
query = 0x0
origin = <optimized out>
source = <optimized out>
source_safe = 0x7f78f82d8710 "app\\/org.gabmus.gnome-feeds\\/x86_64\\/stable"
xpath = 0x7f78f88dcea0 "components[@origin='flathub']/component/bundle[@type='flatpak'][text()='app\\/org.gabmus.gnome-feeds\\/x86_64\\/stable']/.."
error_local = 0x55dbac236640
component = 0x0
#6 gs_flatpak_refine_appstream (self=0x55dbabe3ecd0 [GsFlatpak], app=0x7f78fc0fa560 [GsApp], silo=0x7f78fc00f1f0 [XbSilo], flags=33280, cancellable=0x7f78f80be0e0 [GCancellable], error=0x7f79056a17e8) at ../plugins/flatpak/gs-flatpak.c:2740
origin = <optimized out>
source = <optimized out>
source_safe = 0x7f78f82d8710 "app\\/org.gabmus.gnome-feeds\\/x86_64\\/stable"
xpath = 0x7f78f88dcea0 "components[@origin='flathub']/component/bundle[@type='flatpak'][text()='app\\/org.gabmus.gnome-feeds\\/x86_64\\/stable']/.."
error_local = 0x55dbac236640
component = 0x0
#7 0x00007f790c1ae07e in gs_flatpak_refine_app_unlocked (self=0x55dbabe3ecd0 [GsFlatpak], app=0x7f78fc0fa560 [GsApp], flags=33280, cancellable=0x7f78f80be0e0 [GCancellable], error=0x7f79056a17e8) at ../plugins/flatpak/gs-flatpak.c:2804
old_state = GS_APP_STATE_UPDATABLE_LIVE
locker = 0x55dbabe3ed38
local_error = 0x0
#8 0x00007f790c1b619d in refine_app (error=0x7f79056a17e8, cancellable=0x7f78f80be0e0 [GCancellable], flags=33280, app=0x7f78fc0fa560 [GsApp], plugin=0x55dbabce7cc0 [GsPlugin]) at ../plugins/flatpak/gs-plugin-flatpak.c:362
app = 0x7f78fc0fa560 [GsApp]
i = 0
#9 gs_plugin_refine (plugin=plugin@entry=0x55dbabce7cc0 [GsPlugin], list=list@entry=0x7f78f80be000 [GsAppList], flags=flags@entry=33280, cancellable=cancellable@entry=0x7f78f80be0e0 [GCancellable], error=error@entry=0x7f79056a17e8) at ../plugins/flatpak/gs-plugin-flatpak.c:389
app = 0x7f78fc0fa560 [GsApp]
i = 0
#10 0x00007f791f751e0a in gs_plugin_loader_call_vfunc (helper=0x55dbac28e800, plugin=0x55dbabce7cc0 [GsPlugin], app=<optimized out>, list=0x7f78f80be000 [GsAppList], refine_flags=33280, cancellable=0x7f78f80be0e0 [GCancellable], error=0x7f79056a1a28) at ../lib/gs-plugin-loader.c:567
plugin_func = 0x7f790c1b6100 <gs_plugin_refine>
plugin_loader = 0x55dbabf5d0b0 [GsPluginLoader]
action = GS_PLUGIN_ACTION_REFINE
ret = 1
func = 0x7f790c1b6100 <gs_plugin_refine>
error_local = 0x0
timer = 0x7f78f82511d0
begin_time_nsec = 85090483568514
__func__ = "gs_plugin_loader_call_vfunc"
#11 0x00007f791f751f1b in gs_plugin_loader_run_refine_filter (helper=0x55dbac28e800, list=0x7f78f80be000 [GsAppList], refine_flags=GS_PLUGIN_REFINE_FLAGS_DEFAULT, cancellable=0x7f78f80be0e0 [GCancellable], error=0x7f79056a1a28) at ../lib/gs-plugin-loader.c:831
plugin = 0x55dbabce7cc0 [GsPlugin]
app_list = 0x0
i = 13
plugin_loader = 0x55dbabf5d0b0 [GsPluginLoader]
#12 0x00007f791f7521f9 in gs_plugin_loader_run_refine_internal (helper=0x55dbac28e800, list=0x7f78f80be000 [GsAppList], cancellable=0x7f78f80be0e0 [GCancellable], error=0x7f79056a1a28) at ../lib/gs-plugin-loader.c:873
#13 0x00007f791f754a37 in gs_plugin_loader_run_refine (helper=0x7f78f80c31e0, list=0x7f78f80be000 [GsAppList], cancellable=0x7f78f80be0e0 [GCancellable], error=0x7f79056a1a28) at ../lib/gs-plugin-loader.c:1011
ret = <optimized out>
freeze_list = <optimized out>
helper2 = 0x55dbac28e800
plugin_job = 0x55dbac369340
#14 0x00007f791f75bc3b in gs_plugin_loader_process_thread_cb (task=0x55dbac2001a0 [GTask], object=<optimized out>, task_data=0x7f78f80c31e0, cancellable=0x7f78f80be0e0 [GCancellable]) at ../lib/gs-plugin-loader.c:3306
error = 0x0
helper = 0x7f78f80c31e0
dedupe_flags = <optimized out>
list = 0x7f78f80be000 [GsAppList]
action = GS_PLUGIN_ACTION_GET_UPDATES
plugin_loader = 0x55dbabf5d0b0 [GsPluginLoader]
filter_flags = <optimized out>
refine_flags = <optimized out>
add_to_pending_array = <optimized out>
max_results = <optimized out>
sort_func = <optimized out>
context = 0x7f78f824e4b0
pusher = 0x7f78f824e4b0
begin_time_nsec = 85088947680478
#15 0x00007f791f556def in g_task_thread_pool_thread (thread_data=0x55dbac2001a0, pool_data=<optimized out>) at ../gio/gtask.c:1430
task = 0x55dbac2001a0 [GTask]
#16 0x00007f791f399a54 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:354
task = 0x55dbac2001a0
pool = <optimized out>
#17 0x00007f791f396b62 in g_thread_proxy (data=0x7f78f80c4c00) at ../glib/gthread.c:826
thread = 0x7f78f80c4c00
__func__ = "g_thread_proxy"
#18 0x00007f791e312299 in start_thread (arg=0x7f79056a2640) at pthread_create.c:473
ret = <optimized out>
pd = 0x7f79056a2640
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140157758613056, -5716464626451225679, 140732657955726, 140732657955727, 0, 140157758613056, 5645547325968999345, 5645602809133523889}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = 0
#19 0x00007f791e4806a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95