[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#779467: dpkg: start-stop-daemon sometimes exits with "_cpu_tick_frequency: no such symbol" on kFreeBSD



Hi!

On Sat, 2015-02-28 at 18:21:13 -0600, Jeff Epler wrote:
> Package: dpkg
> Version: 1.17.23+local1
> Severity: important
> Tags: patch

> On a Debian Jessie kFreeBSD system, start-stop-daemon sometimes exits with
> an odd error:
> 
> $ sudo service nfsd restart
> start-stop-daemon: _cpu_tick_frequency: no such symbol
> 
> The specific command invocation which was reliably printing the error
> for me was:
> # start-stop-daemon --stop --quiet --retry=USR1/30/KILL/5 --name nfsd
> start-stop-daemon: _cpu_tick_frequency: no such symbol
> 
> This turns out to be due to file descriptor exhaustion due to calls to
> kvm_openfiles without balancing calls to kvm_close, which is fixed by the
> attached patch.

Right, I had some branch around reworking that code, doing kvm_close()
calls, but I seem to have lost it somehow. In any case here's a minimal
patch that should fix it too. I've not been able to reproduce it, so
it would be nice if you could try it out.

I'll probably try to get this into 1.17.25 targetting jessie.

Thanks,
Guillem
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 6aebe9b..7ae4a7f 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -1247,9 +1247,12 @@ get_proc_stat(pid_t pid, ps_flags_t flags)
 static kvm_t *
 ssd_kvm_open(void)
 {
-	kvm_t *kd;
+	static kvm_t *kd;
 	char errbuf[_POSIX2_LINE_MAX];
 
+	if (kd)
+		return kd;
+
 	kd = kvm_openfiles(NULL, KVM_MEMFILE, NULL, O_RDONLY, errbuf);
 	if (kd == NULL)
 		errx(1, "%s", errbuf);
@@ -1795,8 +1798,6 @@ do_procinit(void)
 			prog_status = pid_status;
 	}
 
-	kvm_close(kd);
-
 	return prog_status;
 }
 #endif

Reply to: