From owner-freebsd-bugs@FreeBSD.ORG Sun May 17 08:00:13 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 367741065672 for ; Sun, 17 May 2009 08:00:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 367EC8FC19 for ; Sun, 17 May 2009 08:00:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n4H8084Q019842 for ; Sun, 17 May 2009 08:00:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n4H80867019834; Sun, 17 May 2009 08:00:08 GMT (envelope-from gnats) Resent-Date: Sun, 17 May 2009 08:00:08 GMT Resent-Message-Id: <200905170800.n4H80867019834@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Mikolaj Golub Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89062106567B for ; Sun, 17 May 2009 07:51:19 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 7913F8FC16 for ; Sun, 17 May 2009 07:51:19 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n4H7pJGm009459 for ; Sun, 17 May 2009 07:51:19 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n4H7pJ9B009456; Sun, 17 May 2009 07:51:19 GMT (envelope-from nobody) Message-Id: <200905170751.n4H7pJ9B009456@www.freebsd.org> Date: Sun, 17 May 2009 07:51:19 GMT From: Mikolaj Golub To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: gnu/134604: Memory leak in gcclibs/libgomp X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2009 08:00:13 -0000 >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 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: