Skip to content

Commit 390e942

Browse files
yuwatakeszybz
authored andcommitted
resolve: do not trigger assertion on exit
By making assert_return() critical, we observe the following: --- Program received signal SIGABRT, Aborted. 0x00007f01320b0884 in __pthread_kill_implementation () from /lib64/libc.so.6 (gdb) bt #0 0x00007f01320b0884 in __pthread_kill_implementation () from /lib64/libc.so.6 #1 0x00007f013205fafe in raise () from /lib64/libc.so.6 #2 0x00007f013204887f in abort () from /lib64/libc.so.6 #3 0x00007f01338d02d6 in log_assert_failed ( text=0x7f01340009e0 "e->state != SD_EVENT_FINISHED", file=0x7f0133fff403 "src/libsystemd/sd-event/sd-event.c", line=1399, func=0x7f01340045a0 <__func__.148> "sd_event_add_time") at ../src/basic/log.c:948 #4 0x00007f01338d0457 in log_assert_failed_return ( text=0x7f01340009e0 "e->state != SD_EVENT_FINISHED", file=0x7f0133fff403 "src/libsystemd/sd-event/sd-event.c", line=1399, func=0x7f01340045a0 <__func__.148> "sd_event_add_time") at ../src/basic/log.c:967 #5 0x00007f0133c7ed83 in sd_event_add_time (e=0x617000022280, ret=0x610000007e98, clock=7, usec=24054941030, accuracy=0, callback=0x4625b4 <on_announcement_timeout>, userdata=0x610000007e40) at ../src/libsystemd/sd-event/sd-event.c:1399 #6 0x00007f0133c7f725 in sd_event_add_time_relative (e=0x617000022280, ret=0x610000007e98, clock=7, usec=1000000, accuracy=0, callback=0x4625b4 <on_announcement_timeout>, userdata=0x610000007e40) at ../src/libsystemd/sd-event/sd-event.c:1462 #7 0x0000000000464cac in dns_scope_announce (scope=0x610000007e40, goodbye=true) at ../src/resolve/resolved-dns-scope.c:1530 #8 0x0000000000504d08 in link_free (l=0x612000023d40) at ../src/resolve/resolved-link.c:83 #9 0x000000000052dbbd in manager_free (m=0x619000000a80) at ../src/resolve/resolved-manager.c:697 #10 0x0000000000562328 in manager_freep (p=0x7f012f800040) at ../src/resolve/resolved-manager.h:198 #11 0x000000000056315a in run (argc=1, argv=0x7fff22b06468) at ../src/resolve/resolved.c:25 #12 0x0000000000563284 in main (argc=1, argv=0x7fff22b06468) at ../src/resolve/resolved.c:99 --- Prompted by systemd#30049 (comment). (cherry picked from commit a4be4ad)
1 parent b2a3703 commit 390e942

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/resolve/resolved-dns-scope.c

+8
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,14 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
14281428
if (scope->protocol != DNS_PROTOCOL_MDNS)
14291429
return 0;
14301430

1431+
r = sd_event_get_state(scope->manager->event);
1432+
if (r < 0)
1433+
return log_debug_errno(r, "Failed to get event loop state: %m");
1434+
1435+
/* If this is called on exit, through manager_free() -> link_free(), then we cannot announce. */
1436+
if (r == SD_EVENT_FINISHED)
1437+
return 0;
1438+
14311439
/* Check if we're done with probing. */
14321440
LIST_FOREACH(transactions_by_scope, t, scope->transactions)
14331441
if (t->probing && DNS_TRANSACTION_IS_LIVE(t->state))

0 commit comments

Comments
 (0)