Bug 197365 - pthread_barrier_destroy() return EBUSY on idle barrier
Summary: pthread_barrier_destroy() return EBUSY on idle barrier
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: threads (show other bugs)
Version: 10.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-threads (Nobody)
Depends on:
Reported: 2015-02-06 11:37 UTC by Florent Guiliani
Modified: 2015-05-15 16:12 UTC (History)
2 users (show)

See Also:

reproduce test case (613 bytes, text/plain)
2015-02-06 11:37 UTC, Florent Guiliani
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florent Guiliani 2015-02-06 11:37:40 UTC
Created attachment 152607 [details]
reproduce test case

pthread_barrier_destroy() can return EBUSY even when the barrier is not in use. The problem was introduced somewhere between FreeBSD 8 and 10.0-RELEASE.

I have attached a simple test case to reproduce the issue. The problem seems related
to the use of uninitialized memory.

pthread_barrier_destroy() is testing bar->b_destroying in thr_barrier.c:

while pthread_barrier_init() did not initialized bar->b_destroying:
Comment 1 commit-hook freebsd_committer 2015-02-06 12:19:08 UTC
A commit references this bug:

Author: kib
Date: Fri Feb  6 12:18:39 UTC 2015
New revision: 278313
URL: https://svnweb.freebsd.org/changeset/base/278313

  Fully initialize allocated memory for the new barrier.  The
  b_destroying member was left uninitialized, which caused spurious

  PR:	197365
  Noted by:	Florent Guiliani <fguiliani@verisign.com>
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Comment 2 Florent Guiliani 2015-02-06 13:25:28 UTC
Thank you for the fix. I was about to post a patch but you were faster than me.