Bug 17433

Summary: libobjc locks mutex before deallocating it
Product: Base System Reporter: mirko.viviani <mirko.viviani>
Component: gnuAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.4-STABLE   
Hardware: Any   
OS: Any   

Description mirko.viviani 2000-03-17 13:20:00 UTC
In the 4.0-RELEASE (and lower) libobjc there is a but in the posix thread
implementation. It locks the mutex before deallocating it.

Anyway in 4.0 is libobjc compiled with thr-posix.c ? I haven't tested 4.0 yet,
but I hope yes.

Fix: 

src/contrib/gcc/objc/thr.c - objc_mutex_deallocate() should be changed to:

int
objc_mutex_deallocate(objc_mutex_t mutex)
{
  int depth;

  /* Valid mutex? */
  if (!mutex)
    return -1;

#if 0
  /* Acquire lock on mutex */
  depth = objc_mutex_lock(mutex);
#endif
  depth = 1;

  /* Call backend to destroy mutex */
  if (__objc_mutex_deallocate(mutex))
    return -1;

  /* Free the mutex structure */
  objc_free(mutex);

  /* Return last depth */
  return depth;
}
How-To-Repeat: 
Run any of the GNUstep application that uses threads linked with libobjc
compiled with thr-posix support.
Comment 1 Mike Barcroft freebsd_committer freebsd_triage 2001-07-22 01:41:47 UTC
State Changed
From-To: open->feedback


Does this problem still occur in newer versions of FreeBSD, 
such as 4.3-RELEASE?
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2002-01-18 16:14:39 UTC
State Changed
From-To: feedback->closed

Automatic feedback timeout.  If additional feedback that warrants 
the re-opening of this PR is available but not included in the 
audit trail, please include the feedback in a reply to this message 
(preserving the Subject line) and ask that the PR be re-opened.