Bug 134604 - [libgcc] [patch] Memory leak in gcclibs/libgomp
Summary: [libgcc] [patch] Memory leak in gcclibs/libgomp
Status: Closed Not Accepted
Alias: None
Product: Base System
Classification: Unclassified
Component: gnu (show other bugs)
Version: 1.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-17 09:00 UTC by Mikolaj Golub
Modified: 2019-04-04 07:07 UTC (History)
2 users (show)

See Also:


Attachments
file.diff (542 bytes, patch)
2009-05-17 09:00 UTC, Mikolaj Golub
no flags Details | Diff
team.c.patch.txt (290 bytes, text/plain)
2009-05-21 20:17 UTC, Mikolaj Golub
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikolaj Golub 2009-05-17 09:00:07 UTC
#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

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:
How-To-Repeat: Compile the test shown above with -fopenmp and run.
Comment 1 Mikolaj Golub 2009-05-17 09:35:05 UTC
Sorry, I have forgotten to mention this. I am running 7.2-STABLE but I think
CURRENT is affected too.

-- 
Mikolaj Golub
Comment 2 Mikolaj Golub 2009-05-21 20:17:28 UTC
The developer has pointed out that correct place to call sem_destroy() is on
returning from gomp_thread_start(). So the patch for libgomp from RELENG_7
(gcc 4.2.1) would be even simpler then provided previously.

-- 
Mikolaj Golub
Comment 3 Alexander Best freebsd_committer freebsd_triage 2010-08-26 12:58:05 UTC
State Changed
From-To: open->suspended

To fix this issue GPL3 licensed code would have to be imported into the FreeBSD 
source tree, which isn't possible due to licensing issues. 
Thus suspend this PR for now.
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:53:34 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"
Comment 5 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-24 09:08:59 UTC
PR was put in suspended state due to fix requiring GPLv3 code import. Closing it as rejected.
Comment 6 Sahib 2019-04-04 07:07:00 UTC
MARKED AS SPAM