connectivity: don't clear "concheck.resolve_cancellable" early in systemd_resolved_resolve_cb()

This can lead to a crash. The code might continue to call
system_resolver_resolve(), then it has no more cancellable.
That means, if the task gets cancelled, then the callback
will still return and result in a crash.

There is no need to cancel or clear the cancellable during
normal operation. It will be cleaned up at the end.

This leads to an assertion error (or possibly crash):

  ...
  #6  0x00005584ff461e67 in system_resolver_resolve_cb (source_object=<optimized out>, res=0x5585016b9190, user_data=user_data@entry=0x558501667800) at src/core/nm-connectivity.c:798
  #7  0x00007f348a02419a in g_task_return_now (task=0x5585016b9190) at ../gio/gtask.c:1219
  #8  0x00007f348a0241dd in complete_in_idle_cb (task=task@entry=0x5585016b9190) at ../gio/gtask.c:1233
  #9  0x00007f3489e263eb in g_idle_dispatch (source=0x7f3464001070, callback=0x7f348a0241d0 <complete_in_idle_cb>, user_data=0x5585016b9190) at ../glib/gmain.c:5897
  ...

Fixes: 57d226d3f0 ('connectivity: resolve hostname ourselves to avoid blocking libcurl')
(cherry picked from commit 62b1f9766a)
This commit is contained in:
Thomas Haller 2022-04-08 15:27:50 +02:00
parent a66e054bd6
commit 64e65d35b3
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -884,8 +884,6 @@ systemd_resolved_resolve_cb(GObject *object, GAsyncResult *res, gpointer user_da
cb_data = user_data;
g_clear_object(&cb_data->concheck.resolve_cancellable);
if (!result) {
/* Never mind. Fallback to the system resolver. */
_LOG2D("can't resolve a name via systemd-resolved: %s", error->message);