This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


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

Re: lin-lwp.c question


   Date: Sun, 17 Sep 2000 01:16:05 -0700
   From: Kevin Buettner <kevinb@cygnus.com>

   Hi Mark,

   In stop_wait_callback () in lin-lwp.c, there is the following
   code:

	 if (WIFEXITED (status) || WIFSIGNALED (status))
	   {
	     gdb_assert (num_lwps > 1);
	     gdb_assert (! is_cloned (lp->pid));

	     gdb_assert (in_thread_list (lp->pid));
	     if (lp->pid != inferior_pid)
	       delete_thread (lp->pid);
	     printf_unfiltered ("[%s exited]\n",
				target_pid_to_str (lp->pid));

	     delete_lwp (lp->pid);
	     return 0;
	   }

   I'm wondering about the reason for the following line:

	     gdb_assert (! is_cloned (lp->pid));

It's a bogus assert :-(.  It's presence was based on the false
assumption that all threads exit with a SIGCHLD, which isn't reported
if __WCLONE is specified in the call to waitpid().  In that case the
code would only be executed if the threads is the "main" thread.
However LinuxThreads uses a special "cancel" signal which is reported
by __WCLONE, and the assertion is tripped.

Unfortunately, The Linux kernels I used to test this code on (2.2.17
and some 2.4.0-test kernels) contain a bug that translate the "cancel"
back into a SIGCHLD so I missed this problem.

Anyway, I believe it is pretty safe to remove the assertion.  Feel
free to check in a patch that does just that.

   I have a simple test program in which I'm (occasionally) seeing
   assertion failures due to the above line.  Unfortunately, it's
   not consistently reproducible, but I can send you the test program
   if you wish to try it for yourself.

I'm afraid many of the outstanding ugs in the code are not
consistently reproducable :-(.

Mark

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