#798935 Starting dnsmasq deadlock with /etc/resolvconf/update-libc.d/squid3

Package:
squid3
Source:
squid
Submitter:
Patrick Cernko
Date:
2025-07-28 19:45:02 UTC
Severity:
important
Tags:
#798935#5
Date:
2015-09-14 09:11:45 UTC
From:
To:
On a system with systemd, dnsmasq and resolvconf installed, the
/etc/resolvconf/update-libc.d/squid3 hook prevents dnsmasq from
starting. As far as I can see, the problem is caused by a deadlock of
"systemctl start dnsmasq.service" in conjunction with "systemctl
reload squid3.service". The latter one is finally called by the
/etc/resolvconf/update-libc.d/squid3 hook which is invoked by dnsmasq
on startup.

A possible solution might be, to check if systemd is running in the
hook and calling

systemctl --no-block reload squid3.service

directly instead of

invoke-rc.d squid3 reload

Best regards,

#798935#10
Date:
2015-09-22 13:00:48 UTC
From:
To:
tags severity important

That hints that the dnsmasq startup sequence is being done the wrong way
around.

Squid and other processes using /etc/resolvconf/update-libc.d/ hooks
rely on the listed NS providing working service *before* the hook is
called. Because the key activity done during the hook is to re-resolve
configuration details using the new NS listings.

Start dnsmasq running, *then* update resolv.conf settings.

Why is dnsmasq deadlocking at all? it should not be depending on things
those hooks do.

We are working on a squid.service upstream and finding all the many,
many broken and missing "features" in systemd.
Making the squid3 package depend on systemd .service files would be
completely wrong for production use.

Amos
(Squid upstream)

#798935#17
Date:
2016-04-13 00:16:37 UTC
From:
To:
Just ran into this bug. The resolvconf hook is indeed run after
dnsmasq is up and running. When I run `sudo systemctl start dnsmasq`
from a terminal, it doesn't return, and running `systemctl` from
another terminal reveals

dnsmasq.service loaded activating start-post start  dnsmasq - A
lightweight DHCP and caching DNS server

i.e. the ExecStartPost task of dnsmasq.service is running. In fact, at
this moment dnsmasq is already working. If I look at running
processes:

$ ps aux | grep -e dns -e resolv
root 2462 0.0 0.6 40540 3496 pts/1 S+ 19:50 0:00 sudo systemctl start dnsmasq
root 2463 0.0 0.4 22488 2512 pts/1 S+ 19:50 0:00 systemctl start dnsmasq
dnsmasq 2474 0.0 0.5 36744 2852 ? S 19:50 0:00 /usr/sbin/dnsmasq -x
/var/run/dnsmasq/dnsmasq.pid -u dnsmasq -r
/var/run/dnsmasq/resolv.conf -7
/etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service
--trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
root 2475 0.0 0.3 4336 1640 ? Ss 19:50 0:00 /bin/sh
/etc/init.d/dnsmasq systemd-start-resolvconf
root 2481 0.0 0.1 4224 652 ? S 19:50 0:00 run-parts --arg=-a
--arg=lo.dnsmasq /etc/resolvconf/update.d
root 2497 0.0 0.1 4224 636 ? S 19:50 0:00 run-parts
/etc/resolvconf/update-libc.d
root 2539 0.0 0.1 4336 756 ? S 19:50 0:00 /bin/sh
/etc/resolvconf/update-libc.d/squid3


So it's /etc/resolvconf/update-libc.d/squid3 that's hanging. After a
few minutes, the status of dnsmasq.service changes to:

dnsmasq.service loaded deactivating stop      start  dnsmasq - A
lightweight DHCP and caching DNS server

And:

$ ps aux | grep -e dns -e resolv
root 2462 0.0 0.6 40540 3496 pts/1 S+ 19:50 0:00 sudo systemctl start dnsmasq
root 2463 0.0 0.4 22488 2512 pts/1 S+ 19:50 0:00 systemctl start dnsmasq
dnsmasq 2474 0.0 0.5 36744 2856 ? S 19:50 0:00 /usr/sbin/dnsmasq -x
/var/run/dnsmasq/dnsmasq.pid -u dnsmasq -r
/var/run/dnsmasq/resolv.conf -7
/etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service
--trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
root 2475 0.0 0.3 4336 1640 ? Ss 19:50 0:00 /bin/sh
/etc/init.d/dnsmasq systemd-start-resolvconf
root 2481 0.0 0.1 4224 652 ? S 19:50 0:00 run-parts --arg=-a
--arg=lo.dnsmasq /etc/resolvconf/update.d
root 2497 0.0 0.1 4224 636 ? S 19:50 0:00 run-parts
/etc/resolvconf/update-libc.d
root 2539 0.0 0.1 4336 756 ? S 19:50 0:00 /bin/sh
/etc/resolvconf/update-libc.d/squid3
root 2581 0.0 0.3 4336 1668 ? Ss 19:51 0:00 /bin/sh
/etc/init.d/dnsmasq systemd-stop-resolvconf
root 2586 0.0 0.1 4224 660 ? S 19:51 0:00 run-parts --arg=-d
--arg=lo.dnsmasq /etc/resolvconf/update.d
root 2598 0.0 0.1 4224 652 ? S 19:51 0:00 run-parts
/etc/resolvconf/update-libc.d
root 2640 0.0 0.1 4336 792 ? S 19:51 0:00 /bin/sh
/etc/resolvconf/update-libc.d/squid3

So systemd decides that the starting of dnsmasq.service has failed
since its ExecStartPost task timed out, and tries to stop
dnsmasq.service. This triggers resolvconf again in dnsmasq.service's
ExecStop task, and another instance of
/etc/resolvconf/update-libc.d/squid3 is run, while the previous copy
hasn't even exited yet.

After a few more minutes, the ExecStop task also times out, and the
original terminal finally returns with

Job for dnsmasq.service failed. See 'systemctl status dnsmasq.service'
and 'journalctl -xn' for details.

#798935#22
Date:
2016-10-26 23:39:18 UTC
From:
To:
Hi,

I just wanted  to  show you  my new web  page layout, take a look  here  <http://rdivyxinko.gumballhelmets.com/e4cr/47>

Best Wishes, Dwayne Bailey

#798935#27
Date:
2016-12-02 01:41:57 UTC
From:
To:
Indeed, I just bumped into this problem.  I recently decided to move
from Polipo to Squid (on my home router), so I installed Squid.
Everything seemed to be dandy until I rebooted, at which point dnsmasq
failed to start, preventing access to the outside world to all other
machines.

How 'bout just adding an & at the end of this reload line?
That's the workaround I'm using right now,


        Stefan

#798935#32
Date:
2018-09-04 04:30:40 UTC
From:
To:
With squid now at version 4 the situation leading to this issue has
changed quite significantly.

Can someone encountering this issue please check and confirm if it is
resolved or present with squid 4.2-2 or later. Older versions are
already known broken in ways that may affect the test result.


Cheers
Amos