misc/158541: ITIMER_REAL stops signalling

Peter Buhr pabuhr at uwaterloo.ca
Thu Jun 30 21:40:07 UTC 2011

>Number:         158541
>Category:       misc
>Synopsis:       ITIMER_REAL stops signalling
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 30 21:40:07 UTC 2011
>Originator:     Peter Buhr
>Release:        RELEASE 8.1
University of Waterloo
FreeBSD xxxx.xxx.xxx 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010 root at almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
The following program stops printing; it hangs spinning in the for loop.  The
problem appears to be a missed signal for ITIMER_REAL to the program.

I have tried 4 versions of the program. Two with durations 9999 and 99999
microseconds, and two different versions to reset the time, one resets the
timer in the handler and the other uses the interval times 9999 and 99999
microseconds, respectively. All 4 versions never complete. The only conclusion
is that the kernel stops sending signals to the program.

The problem does not occur on RELEASE 8.2, so it has been fixed. Nevertheless,
I spent several hours tracking this problem down in RELEASE 8.1. After
isolating the problem, I searched the bug database and found no reference to
this problem. So it should be marked as a bug when searching the bug database
so that others do not have to discover the bug again in RELEASE 8.1.
#include <stdio.h>
#include <signal.h>
#include <sys/time.h>

struct itimerval value;
int itimer_real = 1;

void alarm( int ) {
    itimer_real += 1;
//    signal( SIGALRM, alarm );
//    setitimer(ITIMER_REAL, &value, 0);
    if ( itimer_real % 10 == 0 ) printf( "%d\n", itimer_real );

int main() {
    value.it_value.tv_sec = 0;
    value.it_value.tv_usec = 99999;
    value.it_interval.tv_sec = 0;
    value.it_interval.tv_usec = 99999;

    signal( SIGALRM, alarm );
    setitimer( ITIMER_REAL, &value, 0 );

    for ( ; itimer_real < 1000000; );

// Local Variables: //
// compile-command: "g++ test.cc" //
// End: //



More information about the freebsd-bugs mailing list