🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.bugs
Article #531

[Bug 300887] syslog(3) messages lost when sender calls closelog() right after syslog() and several senders log at once (cron CMD...

#531
From: bugzilla-noreply
Date: Thu, 19 Nov 2026 05:17
85 lines
5396 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300887

            Bug ID: 300887
           Summary: syslog(3) messages lost when sender calls closelog()
                    right after syslog() and several senders log at once
                    (cron CMD lines missing in /var/log/cron since 15.1)
           Product: Base System
           Version: 15.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: knezour@weboutsourcing.cz

After upgrading a machine from 14.4-RELEASE to 15.1-RELEASE-p7 (amd64),
/var/log/cron no longer contains a CMD line for every job when several jobs
start in the same minute. The jobs themselves run; only the log lines are
missing. A second machine on 15.1-RELEASE-p5 shows the same pattern.

Observed:
- Machine 1 (15.1-RELEASE-p7): three "* * * * *" jobs. On 14.4: 60 CMD lines
  per job per hour. On 15.1: 2 or 3 lines per minute instead of 3. The loss
  was reproduced here with the test below.
- Machine 2 (15.1-RELEASE-p5, default /etc/crontab only: atrun */5,
  save-entropy */11, newsyslog hourly): complete logs for two weeks before the
  upgrade (288 atrun lines per day). In the 3.5 days after the upgrade 58 atrun
  lines are missing, 57 of them at minute 00 or 55, i.e. exactly when atrun
  starts together with newsyslog or save-entropy. Not reproduced by a test
  there, log analysis only.
- A third machine (15.1-RELEASE-p5, same default crontab) lost
  only one atrun line in the same period, so the race is timing dependent.
- No "last message repeated" lines, syslogd runs with default flags (-s),
  default syslog.conf.

Analysis:
- cron's grandchild calls log_it(..., "CMD", ...) and immediately closelog()
  (usr.sbin/cron/cron/do_command.c). libc syslog(3) uses a connected
  SOCK_DGRAM socket.
- unp_disconnect() in sys/kern/uipc_usrreq.c moves the datagrams still sitting
in
  the sender's send buffer to the receiver only if the receiver's own buffer is
  empty; otherwise it frees them ("protection against a scenario where a peer
  connects, floods and disconnects").
- So if two or several processes do syslog(); closelog(); before syslogd has
read
  the first datagram, only the first message survives.
- This code is the same in 14.4, as are cron and libc syslog.c; what changed is
  syslogd (kevent loop, Capsicum/casper). Presumably syslogd on 14.4 drained
the
  socket fast enough for the race not to show.

How to reproduce (15.1-RELEASE, any program using libc syslog; here PHP CLI):

php -r 'for ($i=1;$i<=3;$i++) { openlog("TESTcron", LOG_PID, LOG_CRON);
syslog(LOG_INFO, "TEST B message ".$i); closelog(); }'

Result: only "TEST B message 1" is written to /var/log/cron (4 runs: 4 of 12
messages logged, always the first one of each run).

Control 1: one message per process, one second apart: 4 of 4 logged.
Control 2: three messages over one connection, closelog() only at the end: 3 of
3 logged.

Expected: every message accepted by send(2) on the connected log socket is
delivered to syslogd, as on 14.4.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <bug-300887-227@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.bugs
Subject: [Bug 300887] syslog(3) messages lost when sender calls closelog()
 right after syslog() and several senders log at once (cron CMD lines missing
 in /var/log/cron since 15.1)
Date: Thu, 19 Nov 2026 05:17:20 +0000
Organization: Newsgate at muc.de e.V.
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-300887-227@https.bugs.freebsd.org/bugzilla/>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="84807"; mail-complaints-to="news-admin@muc.de"
X-Original-To: bugs@mlmmj.nyi.freebsd.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1795065440;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=jfK+mpiP8NtiON9GrEjz5QppVBI448HwLHebhf/KAjo=;
	b=vL25tfPA42F0CI3VBq450TX36vv5l0WgvKfsfp75yGTODjuj/GlU2kgVsT6au8cj1udM+7
	SmunBi83KhOBd5jRrnwdd7Ls4JApvcXAQOhLCA2UvnE3fBfWxX0vi0xGdjnxovRsAZYvUI
	HU/l09OHF1Paw+xelJeroUwkq/4edcDnaJwveaZ0BAJtyRUmgS/WMBD7si+yXLQNm+PAP2
	+V85T9sDN/nF9N9mALW4e1vymSdySgDu9/GxfWeQ2sgdE3Sr9x0UI3UeitDhrcWvtjINrs
	zZoxUYacMGt6nmcM3dLdBPJa9853uANqbjipOeam25Rskh3feJHKEvlaJk2EtQ==
X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
Auto-Submitted: auto-generated
Precedence: list
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes