threads/72429: threads blocked in stdio (fgets, etc) are not cancellable in 5.3 (works in 4.x)

Mark Gooderum mark at verniernetworks.com
Thu Oct 7 12:50:34 PDT 2004


>Number:         72429
>Category:       threads
>Synopsis:       threads blocked in stdio (fgets, etc) are not cancellable in 5.3 (works in 4.x)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 07 19:50:27 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Mark Gooderum
>Release:        5.3 Beta 6
>Organization:
Vernier Networks, Inc.
>Environment:
FreeBSD 172.20.1.199 5.3-BETA6 FreeBSD 5.3-BETA6 #0: Thu Oct  7 09:35:49 PDT 2004     root at eagle.jumpadmin.net:/usr/build/ambit2/freebsd5/sys/i386/compile/VNISMP  i386

>Description:
With libc_r in 4.9 a function blocked in stdio (say fgets()) is cancellable.  The call from fgets() to the I/O in FreeBSD 4.9 with libc/libc_r:

fgets()
  __srefill()
    __sread() (via fp->_read())
      _read() (now in libc_r)
        calls thread_enter_cancellation_point()
        calls __read()
          __read() does the uthread I/O voodoo
          thread can be cancelled...

With FreeBSD 5.3 libc/libpthread:

fgets()
 __srefill()
   __sread() (via fp->_read())
     _read() - weak symbol for __sys_read() in libc
       (libpthread only defines __read and a weak reference from read
        to __read)
        thread can't be cancelled - it's blocked in real system call 
        and thread_enter_cancellation_point() was never called

With FreeBSD 5.3 libc/libpthread:

fgets()
  __srefill()
    __sread() (via fp->_read())
      _read() (now in libc_r)
        _read() does the uthread I/O voodoo
          thread can't be cancelled as
          thread_enter_cancellation_point() was never called, that
          is in __read()...


>How-To-Repeat:
Try to pthread_cancel() a thread blocked in any stdio operation (fgets, fread, etc), it will never cancel.

>Fix:
Given the current conventions for _foo, __foo and foo it seems like __sread et. al. should be calling the foo() versions of the functions so they get wrapped as cancellation points.

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


More information about the freebsd-threads mailing list