Date: Sun, 17 May 2009 07:51:19 GMT From: Mikolaj Golub <to.my.trociny@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: gnu/134604: Memory leak in gcclibs/libgomp Message-ID: <200905170751.n4H7pJ9B009456@www.freebsd.org> Resent-Message-ID: <200905170800.n4H80867019834@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 134604 >Category: gnu >Synopsis: Memory leak in gcclibs/libgomp >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun May 17 08:00:07 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Mikolaj Golub >Release: >Organization: >Environment: >Description: #include <omp.h> int n = 4, m = 2; int main () { for (;;) { int i; #pragma omp parallel for num_threads(m) for(i = 0; i < 1; i++) {} #pragma omp parallel for num_threads(n) for(i = 0; i < 1; i++) {} } return 0; } When run on freebsd, this test shows constant growth of virtual memory usage. Memory growth is observed only when m != n. There is some discussion of this problem on freebsd-hackers: http://lists.freebsd.org/pipermail/freebsd-hackers/2009-May/028552.html The problem has also been reported to gcc mainstream: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40174 >How-To-Repeat: Compile the test shown above with -fopenmp and run. >Fix: The problem is in libgomp/team.c. gomp_thread_start() does sem_init() but sem_destroy() is never called. Attached patch solves the problem for me. Patch attached with submission follows: --- contrib/gcclibs/libgomp/team.c.orig 2009-05-16 17:32:57.000000000 +0300 +++ contrib/gcclibs/libgomp/team.c 2009-05-16 19:16:37.000000000 +0300 @@ -164,9 +164,12 @@ new_team (unsigned nthreads, struct gomp static void free_team (struct gomp_team *team) { + int i; free (team->work_shares); gomp_mutex_destroy (&team->work_share_lock); gomp_barrier_destroy (&team->barrier); + for(i = 1; i < team->nthreads; i++) + gomp_sem_destroy (team->ordered_release[i]); gomp_sem_destroy (&team->master_release); free (team); } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905170751.n4H7pJ9B009456>