This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix nptl/tst-cancel7 for non-bash shells


On Mon, Oct 29, 2012 at 09:37:34AM -0400, Carlos O'Donell wrote:
> On Sun, Oct 28, 2012 at 9:15 PM, Rich Felker <dalias@aerifal.cx> wrote:
> > This issue caused me to take a look at the implementation of system's
> > handling of cancellation, which turns out to have a serious bug:
> >
> > http://sourceware.org/bugzilla/show_bug.cgi?id=14782
> >
> > It should be easy to fix; the fix is a purely-red patch (all -'s).
> 
> While your analysis looks correct the more interesting question to me
> is "Why was this added in the first place?" Can you dig a bit more and
> see if we can determine the reason for the deviation from the standard?
> Clearly we went to a lot of work to implement the current behaviour and
> I'd like to know why.

Where would you suggest I start? "system" is not the easiest function
to search the bug tracker for, but I just did and the only resolved
bugs I found related to system were invalid (requests for it to close
the parent's file descriptors or catch the SIGCHLD). As such, I don't
think this code was written to fix any bug.

My best guess is that whoever wrote the code saw the "enable async
cancel, make syscall, restore cancellation" idiom around system calls,
and wrongly assumed it was also the right thing to do for cancellable
library calls. Note that this idiom is actually also wrong for system
calls; see:

http://sourceware.org/bugzilla/show_bug.cgi?id=12683

and XSH 2.9.5 Thread Cancellation, subheading Cancellation Points:

  The side-effects of acting upon a cancellation request while
  suspended during a call of a function are the same as the
  side-effects that may be seen in a single-threaded program when a
  call to a function is interrupted by a signal and the given function
  returns [EINTR]. Any such side-effects occur before any cancellation
  cleanup handlers are called.


Rich



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]