Bug 45240 - parallel.c: GOMP_parallel_end locks a mutex but fails to unlock it after atomic operation complete
Summary: parallel.c: GOMP_parallel_end locks a mutex but fails to unlock it after atom...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgomp (show other bugs)
Version: 4.5.1
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2010-08-09 17:40 UTC by Shreyas Prasad
Modified: 2010-12-07 18:59 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shreyas Prasad 2010-08-09 17:40:44 UTC
In parallel.c, if HAVE_SYNC_BUILTINS is #undef'ed, then GOMP_parallel_end uses a mutex to atomically modify the team->nthreads field.  The mutex that is used to atomically write to nthreads is locked but never unlocked.

parallel.c, GOMP_parallel_end:

#ifdef HAVE_SYNC_BUILTINS
	  __sync_fetch_and_add (&gomp_remaining_threads_count,
				1UL - team->nthreads);
#else
	  gomp_mutex_lock (&gomp_remaining_threads_lock);
	  gomp_remaining_threads_count -= team->nthreads - 1;
#endif
Comment 1 Jakub Jelinek 2010-12-02 14:30:41 UTC
Author: jakub
Date: Thu Dec  2 14:30:37 2010
New Revision: 167370

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167370
Log:
	PR libgomp/45240
	* parallel.c (GOMP_parallel_end): Unlock gomp_remaining_threads_lock
	at the end if sync builtins aren't supported.

Modified:
    trunk/libgomp/ChangeLog
    trunk/libgomp/parallel.c
Comment 2 Jakub Jelinek 2010-12-07 15:26:40 UTC
Author: jakub
Date: Tue Dec  7 15:26:37 2010
New Revision: 167547

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167547
Log:
	Backport from mainline
	2010-12-02  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/45240
	* parallel.c (GOMP_parallel_end): Unlock gomp_remaining_threads_lock
	at the end if sync builtins aren't supported.

Modified:
    branches/gcc-4_5-branch/libgomp/ChangeLog
    branches/gcc-4_5-branch/libgomp/parallel.c
Comment 3 Jakub Jelinek 2010-12-07 15:45:53 UTC
Fixed.
Comment 4 Jakub Jelinek 2010-12-07 18:59:06 UTC
Author: jakub
Date: Tue Dec  7 18:59:03 2010
New Revision: 167560

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167560
Log:
	Backport from mainline
	2010-12-02  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/45240
	* parallel.c (GOMP_parallel_end): Unlock gomp_remaining_threads_lock
	at the end if sync builtins aren't supported.

Modified:
    branches/gcc-4_4-branch/libgomp/ChangeLog
    branches/gcc-4_4-branch/libgomp/parallel.c