Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Mar 2006 16:17:28 GMT
From:      john gladkih <john@kak-sam.to>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   threads/94176: KSE: sigwait doesn't recieve SIGWINCH sent by pthread_kill() or kill -WINCH
Message-ID:  <200603071617.k27GHSM5000487@www.freebsd.org>
Resent-Message-ID: <200603071620.k27GK4pj039131@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         94176
>Category:       threads
>Synopsis:       KSE: sigwait doesn't recieve SIGWINCH sent by pthread_kill() or kill -WINCH
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 07 16:20:04 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     john gladkih
>Release:        5.4-RELEASE, 5.3-RELEASE
>Organization:
>Environment:
FreeBSD freebsd54.i.drweb.ru 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May  8 10:21:06 UTC 2005     root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
sigwait() doesn't recieve SIGWINCH (SIGIO and maybe some others signal) sent by pthread_kill() from another thread or even from kill -WINCH. there is no such issue on 5.2.1 and older with libc_r.
>How-To-Repeat:
[~]> cat t.cc 
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

sigset_t blk;

void *thread( void* ) {
  pthread_sigmask( SIG_BLOCK, &blk, NULL );
  printf( "sigwait()\n" );
  int sig, rc = sigwait( &blk, &sig );
  printf( "got %d (rc=%d)\n", sig, rc );
  printf( "no bug!\n" );
  _exit( 0 );
}

int main() {
  sigemptyset( &blk );
  sigaddset( &blk, SIGWINCH );

  sigprocmask( SIG_BLOCK, &blk, NULL );
  pthread_sigmask( SIG_BLOCK, &blk, NULL );

  pthread_attr_t attr;
  pthread_t tid;
  
  pthread_attr_init( &attr );
  pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
  pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );

  printf( "pthread_create=%d\n", pthread_create( &tid, &attr, thread, 0 ) );
  pthread_attr_destroy( &attr );

  sleep( 5 );
  printf( "pthread_kill=%d\n", pthread_kill( tid, SIGWINCH ) );
  sleep( 5 );
  printf( "bug!\n" );
  return 1;
}
[~]> g++ -o t t.cc -lpthread
[~]> ./t
sigwait()
pthread_create=0
pthread_kill=0
bug!

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603071617.k27GHSM5000487>