Bug 39790 - Crash on receiving 2 SIGUSR1 in a short period of time
Summary: Crash on receiving 2 SIGUSR1 in a short period of time
Status: RESOLVED FIXED
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: 1.2.8
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2006-06-12 18:10 UTC by Stefan Hojer
Modified: 2007-07-04 03:02 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Hojer 2006-06-12 18:10:14 UTC
The server crashes after receiving 2 SIGUSR1 within a very short timeframe. I
personally ran into this problem by using a logrotate script that sends SIGUSR1
after each individual logrotation.

The last lines in error_log are
[Sat Jun 10 03:51:10 2006] [notice] SIGUSR1 received.  Doing graceful restart
[Sat Jun 10 03:51:10 2006] [notice] Digest: generating secret for digest
authentication ...
[Sat Jun 10 03:51:11 2006] [crit] (4)Interrupted system call: Digest: error
generating secret: Interrupted system call
Configuration Failed

The problem seems to be located in apr_generate_random_bytes() which is called
by mod_auth_digest.

It returns a failure on receiving a signal while reading from /dev/random.
Applying the following patch should fix the problem:

diff --recursive httpd-2.0.58/srclib/apr/misc/unix/rand.c
httpd-2.0.58-fixed/srclib/apr/misc/unix/rand.c
70c70,73
<             return errnum;
---
>             if (errnum == EINTR)
>                 fd = -1; /* force open() again if read() was interrupted */
>             else
>                 return errnum;
Comment 1 Victor Trac 2006-07-29 08:18:34 UTC
I think I just ran into this problem.  error_log:

[Sat Jul 29 03:10:01 2006] [notice] Digest: generating secret for digest
authentication ...
[Sat Jul 29 03:10:01 2006] [notice] Digest: done
[Sat Jul 29 03:10:01 2006] [notice] Apache configured -- resuming normal operations
[Sat Jul 29 03:10:02 2006] [notice] Graceful restart requested, doing restart
[Sat Jul 29 03:10:03 2006] [notice] Digest: generating secret for digest
authentication ...
[Sat Jul 29 03:10:03 2006] [notice] Digest: done
[Sat Jul 29 03:10:03 2006] [notice] Apache configured -- resuming normal operations
[Sat Jul 29 03:10:05 2006] [notice] Graceful restart requested, doing restart
[Sat Jul 29 03:10:05 2006] [notice] Digest: generating secret for digest
authentication ...
[Sat Jul 29 03:10:05 2006] [notice] Digest: done
[Sat Jul 29 03:10:06 2006] [notice] Apache configured -- resuming normal operations
[Sat Jul 29 03:10:06 2006] [notice] Graceful restart requested, doing restart
[Sat Jul 29 03:10:06 2006] [notice] Digest: generating secret for digest
authentication ...
[Sat Jul 29 03:10:06 2006] [notice] Digest: done
[Sat Jul 29 03:10:06 2006] [notice] Apache configured -- resuming normal operations
[Sat Jul 29 03:10:06 2006] [notice] Graceful restart requested, doing restart
[Sat Jul 29 03:10:06 2006] [notice] Digest: generating secret for digest
authentication ...
[Sat Jul 29 03:10:06 2006] [crit] (4)Interrupted system call: Digest: error
generating secret: Interrupted system call
Configuration Failed

Server version: Apache/2.0.58
Comment 2 Ian P. Christian 2007-01-12 09:18:09 UTC
I also just got this problem - at 03:10 too - this is when my logs rotate, so
preumably is caused by the 'reload' that logrotate does:

/var/log/apache2/*log {
  missingok
  notifempty
  sharedscripts
  postrotate
  /etc/init.d/apache2 reload > /dev/null 2>&1 || true
  endscript
}
Comment 3 Joe Orton 2007-01-12 09:23:42 UTC
This is a bug in apr_generate_random_bytes, it should handle EINTR.
Comment 4 Joe Orton 2007-07-04 03:02:02 UTC
Fixed on the trunk - thanks for the report.

http://svn.apache.org/viewvc?view=rev&revision=553146