From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2213 invoked by alias); 16 May 2014 15:08:57 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 2173 invoked by uid 48); 16 May 2014 15:08:52 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgomp/61200] internal compiler error: Segmentation fault, assert & openmp Date: Fri, 16 May 2014 15:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg01462.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-05-16 Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek --- More reduced testcase: int main () { int var = 1; #pragma omp parallel if (var != 1) __builtin_abort (); #pragma omp task shared(var) var = 2; return 0; } The problem is that previously non-addressable var needs to be turned into addressable because it is shared in the task, where we can't use copy-in/out, but by that time we have already processed the #pragma omp parallel and decided to copy-in/out var there, but later on it is TREE_ADDRESSABLE and thus we expect that copy-in/out is not used in that case. Unfortunately, I believe we really have to force no copy-in/out in that case, consider: #include #include #include volatile int x; void foo () { int var = 1; int i; for (i = 0; i < 2; i++) { if (i == 1) { #pragma omp parallel if (x) var++; else { #pragma omp single sleep (4); } } else { #pragma omp task shared(var) { sleep (2); var = 2; } } } #pragma omp taskwait if (var != 2) abort (); } int main () { omp_set_nested (1); #pragma omp parallel #pragma omp single foo (); return 0; } If we decide to use copy-in/out in #pragma omp parallel for var, but the task will be run in parallel with the #pragma omp parallel, then if the #pragma omp parallel is entered before var = 2 is set in another thread, it will copy in value 1, then var = 2 happens and if #pragma omp parallel finishes after that, it will copy out the value it copied in (1) and the testcase will break, even when there is actually no data-race originally (the compiler doesn't know the parallel will not touch var at all).