Bug 500354 - syslogd stops writing any messages to /dev/console after an EINTR in syscall
syslogd stops writing any messages to /dev/console after an EINTR in syscall
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: sysklogd (Show other bugs)
4.7
All Linux
urgent Severity high
: rc
: ---
Assigned To: Peter Vrabec
BaseOS QE
: Patch, ZStream
Depends On:
Blocks: 485811 506683 618203
  Show dependency treegraph
 
Reported: 2009-05-12 08:27 EDT by Olivier Fourdan
Modified: 2013-03-03 21:48 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: SIGALRM signal is triggered during a writev() (which can happen when writing so a slow console via serial) Consequence: syslogd stops writing messages to /dev/console. Fix: Reschedule the ALARM just prior to call writev(). Recompute iovec when writev() could not write all data to avoid messages being half written to the log Result: syslogd keeps writing messages to /dev/console.
Story Points: ---
Clone Of:
: 506683 (view as bug list)
Environment:
Last Closed: 2011-02-16 09:07:28 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Proposed patch (1017 bytes, patch)
2009-05-12 08:27 EDT, Olivier Fourdan
no flags Details | Diff
Proposed patch (992 bytes, patch)
2009-06-04 10:48 EDT, Olivier Fourdan
no flags Details | Diff
Proposed patch (3.65 KB, patch)
2009-06-08 09:34 EDT, Olivier Fourdan
no flags Details | Diff
Proposed patch (451 bytes, patch)
2009-06-11 12:45 EDT, Olivier Fourdan
no flags Details | Diff
Proposed patch (3.48 KB, patch)
2009-06-11 13:11 EDT, Olivier Fourdan
no flags Details | Diff

  None (edit)
Description Olivier Fourdan 2009-05-12 08:27:33 EDT
Created attachment 343579 [details]
Proposed patch

Description of problem:

The fix for bug #140983 makes system calls interruptible with SIGALRM.

But if that signal is triggered during a writev() (which can happen when sriting so a slow console via serial), syslog will print a message "/dev/console: Interrupted system call" and stop logging to console.

Version-Release number of selected component (if applicable):

sysklogd-1.4.1-26_EL

How reproducible:

Just once in the customer's environment. But reproducer provided by our partner.

Steps to Reproduce:

1. Connect the serial console to system.
2. Edit /etc/syslog.conf as follows to have syslogd write many messages to
   /dev/console.

---
[/etc/syslog.conf]
*.debug               /dev/console
---

3. Execute the following example program to log messages continuously to syslog.

8<-------8<-------8<-------8<-------8<-------

#include<stdio.h>
#include<syslog.h>

int main(void)
{
        int i;
        for(i=0;;i++)
                syslog(LOG_DEBUG,"test--%d",i);

        return 0;

}

8<-------8<-------8<-------8<-------8<-------

Actual Results:

syslogd does not write any messages to /dev/console.

Expected Results:

syslogd writes any messages to /dev/console.

Additional info:

I could not reproduce the issue internally using the technique described, however based on the description, I believe the following attached patch might help with the issue.

A test package has been given to our partner, awaiting test results.
Comment 2 Olivier Fourdan 2009-05-15 04:28:20 EDT
Comment on attachment 343579 [details]
Proposed patch

Patch is causing more bad than good.
Comment 6 Olivier Fourdan 2009-06-04 10:48:37 EDT
Created attachment 346544 [details]
Proposed patch

Same patch as previous, except that it repeats the latest writev() call instead of returning.
Comment 9 Olivier Fourdan 2009-06-08 09:34:44 EDT
Created attachment 346869 [details]
Proposed patch

Third version. Now if writev() cannot write all the data to the file descriptor, the iovec is properly updated and another attempt to writev() is done.

This way no data is lost.
Comment 10 Olivier Fourdan 2009-06-11 12:45:36 EDT
Created attachment 347437 [details]
Proposed patch

A different approach to the problem.

This patch simply just reschedules the ALARM signal prior to log the messages.

So if a writev() is blocked and an alarm occurs, the log is closed and syslog keeps going on.

But by rescheduling the alarm just before calling writev() it virtually avoids the signal to be triggered during the writev() by accident.

This approach is preferred by our customer.
Comment 11 Olivier Fourdan 2009-06-11 13:11:18 EDT
Created attachment 347440 [details]
Proposed patch

Well, another patch, hopefully the last one.

This patch is actually a mix of my two previous patches.

  - Reschedule the ALARM just prior to call writev() to make avoid a signal
    coming up during the writev()
  - Still recompute iovec when writev() could not write all data to avoid
    messages being half written to the log.
Comment 20 Florian Nadge 2011-01-19 10:41:46 EST
Please be so kind and add a few key words to the technical note of this
bugzilla entry using the following structure:

Cause:

Consequence:

Fix:

Result:


For details, see:
https://bugzilla.redhat.com/page.cgi?id=fields.html#cf_release_notes

Thanks
Comment 21 Florian Nadge 2011-01-19 10:41:47 EST
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:

Consequence:

Fix:

Result:
Comment 22 Peter Vrabec 2011-01-20 11:18:40 EST
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,7 +1,12 @@
 Cause:
+SIGALRM signal is triggered during a writev() (which can happen when writing so a slow console via serial)
 
 Consequence:
+syslogd stops writing messages to /dev/console.
 
 Fix:
+Reschedule the ALARM just prior to call writev().
+Recompute iovec when writev() could not write all data to avoid messages being half written to the log
 
-Result:+Result:
+syslogd keeps writing messages to /dev/console.
Comment 23 errata-xmlrpc 2011-02-16 09:07:28 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0225.html

Note You need to log in before you can comment on or make changes to this bug.