public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Bug in testsuite/gdb.base/tls.c
@ 2003-07-29 20:07 Michael Elizabeth Chastain
  2003-07-29 20:56 ` Elena Zannoni
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Elizabeth Chastain @ 2003-07-29 20:07 UTC (permalink / raw)
  To: ezannoni; +Cc: gdb

I'm seeing a lot of test suite hangs with the new tls.c.
I tracked it down to this code:

  for( i = 0; i < N_THREADS; i++ )
    {
      do
	{
	  errno = 0;

	  if (sem_wait (&tell_main) == -1)
	    {
	      if (errno != EINTR)
		{
		  ...
		  return;
		}
	      ...
	    }
	  }
	  while (errno == EINTR);
    }

It turns out that errno can be EINTR even when the return value is 0!
That screws up the loop counter.

This happened with Red Hat Linux 8, glibc 2.2.93-5-rh.  It is sensitive
to the placement of breakpoints, which is not surprising.

I think it's normal Unix semantics that when the return value is zero,
errno has no meaning.

I'll code up a patch for tls.c, on those lines.

Michael C

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug in testsuite/gdb.base/tls.c
  2003-07-29 20:07 Bug in testsuite/gdb.base/tls.c Michael Elizabeth Chastain
@ 2003-07-29 20:56 ` Elena Zannoni
  0 siblings, 0 replies; 2+ messages in thread
From: Elena Zannoni @ 2003-07-29 20:56 UTC (permalink / raw)
  To: Michael Elizabeth Chastain; +Cc: ezannoni, gdb

Michael Elizabeth Chastain writes:
 > I'm seeing a lot of test suite hangs with the new tls.c.
 > I tracked it down to this code:
 > 
 >   for( i = 0; i < N_THREADS; i++ )
 >     {
 >       do
 > 	{
 > 	  errno = 0;
 > 
 > 	  if (sem_wait (&tell_main) == -1)
 > 	    {
 > 	      if (errno != EINTR)
 > 		{
 > 		  ...
 > 		  return;
 > 		}
 > 	      ...
 > 	    }
 > 	  }
 > 	  while (errno == EINTR);
 >     }
 > 
 > It turns out that errno can be EINTR even when the return value is 0!
 > That screws up the loop counter.

Whoops, never seen this one happening on my systems, just (bad) luck I guess.

 > 
 > This happened with Red Hat Linux 8, glibc 2.2.93-5-rh.  It is sensitive
 > to the placement of breakpoints, which is not surprising.
 > 
 > I think it's normal Unix semantics that when the return value is zero,
 > errno has no meaning.

Yes, true. 

"All semaphore functions introduced by POSIX.1b use the old error
reporting mechanism. These functions return 0 on success and -1 on
error, with errno set to the appropriate error"

Note how it carefully avoids mentioning what happens to errno in case
of success.

 > 
 > I'll code up a patch for tls.c, on those lines.
 > 

thanks
elena


 > Michael C

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-07-29 20:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29 20:07 Bug in testsuite/gdb.base/tls.c Michael Elizabeth Chastain
2003-07-29 20:56 ` Elena Zannoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).