Bug 200429 - sysutils/rsyslog8 endless loop when started at boot time with some rules to write on the console
Summary: sysutils/rsyslog8 endless loop when started at boot time with some rules to w...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Brad Davis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-24 18:11 UTC by Alexandre Fenyo
Modified: 2015-05-28 15:49 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (brd)


Attachments
patch to correct the bug (366 bytes, text/plain)
2015-05-24 18:11 UTC, Alexandre Fenyo
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Fenyo 2015-05-24 18:11:35 UTC
Created attachment 157101 [details]
patch to correct the bug

Hi,

This bug report is about the four rsyslog ports: sysutils/rsyslog8, sysutils/rsyslog7, sysutils/rsyslog8-devel, sysutils/rsyslog7-devel.

When rsyslog is started at boot time (for instance by setting rsyslogd_enable="YES" in rc.conf(5), by adding "service rsyslogd onestart" in rc.local(8), or by simply adding the daemon path and args in rc.local(8)), and when rsyslog is simultaneously configured to output some streams to /dev/console, the daemon will start correctly but, at the near end of the boot sequence of the operating system, it will fail permanently, in an endless loop, using 100% CPU.

Attached to this bug report, please find a patch to correct this behaviour. To add this patch to the port, just add the file to the "files" directory. Note that the patch is named *.c2 since another patch for the same file is currently discussed in bug report 200270.

Here is a complete explanation of the steps that make the bug happen:

1- when init(8) launches rc(8) scripts, rsyslogd starts

2- rsyslogd reads rsyslog.conf(5) and if some stuff must be logged to the console, because of a line like "*.err;kern.warning;auth.notice;mail.crit /dev/console" in the configuration file, the daemon calls open(2) to get a file descriptor to write on "/dev/console". It starts writing corresponding logs to this descriptor.

3- Later during the boot sequence, init(8) configures the console, and for this to be done, it starts by calling the revoke(2) syscall: revoke("/dev/console") is the first line of code in /usr/src/sbin/init/init.c:open_console().

4- Once /dev/console is revoked, further writes to any file descriptor previously opened on this file return -1 with ENXIO as errno.

5- thus, rsyslogd gets this error in runtime/Stream.c:doWriteCall(), and calls runtime/stream.c:tryTTYRecover() since the error occured on a tty.

6- but runtime/stream.c:tryTTYRecover() tries to reopen the tty only if the error is EIO on Linux or EBADF on any other operating system. Since the error is ENXIO, that is distinct from EBADF, runtime/stream.c:tryTTYRecover() returns RS_RET_OK and runtime/stream.c:doWriteCall() loops, endlessly.

Sincerely,
Comment 1 commit-hook freebsd_committer freebsd_triage 2015-05-28 15:44:23 UTC
A commit references this bug:

Author: brd
Date: Thu May 28 15:44:04 UTC 2015
New revision: 387739
URL: https://svnweb.freebsd.org/changeset/ports/387739

Log:
  Update sysutils/rsyslog8 to 8.10.0

  Include a few bug fixes:
  1) Endless loop at boot time
  2) Console output starting on the previous line

  PR:		200429 [1]
  PR:		200270 [2]
  Submitted by:	Alexandre Fenyo <fbsd.bugzilla@fenyo.net> [1 and 2]
  Approved by:	bdrewery (mentor)

Changes:
  head/sysutils/rsyslog8/Makefile
  head/sysutils/rsyslog8/distinfo
  head/sysutils/rsyslog8/files/patch-plugins_imfile_imfile.c
  head/sysutils/rsyslog8/files/patch-runtime_stream.c
Comment 2 Brad Davis freebsd_committer freebsd_triage 2015-05-28 15:49:56 UTC
Thank you for your work tracking this down!

I need to depreciate the rsyslog7 port, so I only am committing it to the rsyslog8 port.