Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jul 1999 08:42:03 -0700 (PDT)
From:      jin@george.lbl.gov
To:        j_guojun@lbl.gov, nate@mt.sri.com
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: kern/11984: pthread_kill cannot kill select() threads, etc.
Message-ID:  <199907091542.IAA04652@george.lbl.gov>

next in thread | raw e-mail | index | archive | help
} > Subject: Re: kern/11984: pthread_kill cannot kill select() threads, etc.
} > Date: Thu, 08 Jul 1999 12:46:56 -0700
} 
} Note, according the PR, you are running:
} 
} >Release:        FreeBSD 3.2-RELEASE i386
} 
} > 
} >  By tracing downto c_r library, two problems have been found:
} >  
} >  (1) pthread_exit(void *status)
} >  {
} >       int             sig;
} >       long            l;
} >       pthread_t       pthread;
} >  
} >       /* Check if this thread is already in the process of exiting: */
} >       if ((_thread_run->flags & PTHREAD_EXITING) != 0) {
} >               char msg[128];
} >               snprintf(msg,"Thread %p has called pthread_exit() from a destruc
} tor.
} >  POSIX 1003.1 1996 s16.2.5.2 does not allow this!",_thread_run);
} >               PANIC(msg);
} >       }
} >  
} >       /* Flag this thread as exiting: */
} >       _thread_run->flags |= PTHREAD_EXITING;
} >  ...
} >  }
} >  
} >  PTHREAD_EXITING is defined as 0x100, but _thread_run->flags is type of
} >  char.
} >
} >  So, PTHREAD_EXITING can never be checked or set.
} 
} Huh?  From 3.2-stable (which is the same as 3.2R), pthread_private.h
} 
} SCLASS struct pthread   * volatile _thread_run
} 
} struct pthread {
} ....
}         /* Miscellaneous data. */
}         int             flags;
} #define PTHREAD_FLAGS_PRIVATE   0x0001
} #define PTHREAD_EXITING         0x0002
} #define PTHREAD_FLAGS_QUEUED    0x0004  /* in queue (qe is used) */
} #define PTHREAD_FLAGS_TRACE     0x0008
} 
} And, from current:
} SCLASS struct pthread   * volatile _thread_run
} 
} struct pthread {
} .....
}         /* Miscellaneous data. */
}         int             flags;  
} #define PTHREAD_FLAGS_PRIVATE   0x0001
} #define PTHREAD_EXITING         0x0002
} #define PTHREAD_FLAGS_IN_CONDQ  0x0004  /* in condition queue using qe link*/
} #define PTHREAD_FLAGS_IN_WORKQ  0x0008  /* in work queue using qe link */
} #define PTHREAD_FLAGS_IN_WAITQ  0x0010  /* in waiting queue using pqe link*/
} #define PTHREAD_FLAGS_IN_PRIOQ  0x0020  /* in priority queue using pqe link*/
} #define PTHREAD_FLAGS_TRACE     0x0040  /* for debugging purposes */
} 
} flags and PTHREAD_EXITING are different that what you claim.
} 
} Which version of FreeBSD are you using?  In 3.0, it was a char, so I'll
} bet you are using a buggy version of the library.  Please update to a
} more recent version, which has these bugs fixed.

Sorry for the confusion. That was in 2.2.8-RELEASE. The problem is the
gdb get core dump under 3.2-RELEASE when attach the hanging process,
so I did debugging under 2.2.8-RELEASE.

Yes, part of the problem 1 is fixed in 3.2-RELEASE, but the flags is not
checked any where, which causes problem 2 still in 3.2.

} As far as the second issue, I suspect (but did not review the code) that
} the error may be fixed in more recent versions of the code, which have
} had substantial changes since 3.0R.  (Even 3.1R has most of the fixes in
} place.)
} 
} 
} Nate

I will look into the latest SNAP, but I doubt it is fixed. The entire idea
is still there. That is, the GC is still waiting for PS_DEAD thread to do
cond_signal. Since part of the problem (1) is improved, so we can check
further on the (flags & PTHREAD_EXITING) before doing cond_waiting on each
PS_DEAD thread, and everything should work.

If you agree this logic, I will examine the code and add this conditional
code to fix the problem.

If you think there may be other problems, we can discuss on it.

Thanks,

	-Jin



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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