public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-61200-4-qHuJULPFgz@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-61200-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-05-16 Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- 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 <omp.h> #include <stdlib.h> #include <unistd.h> 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).
next prev parent reply other threads:[~2014-05-16 15:08 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-05-16 13:28 [Bug libgomp/61200] New: " psxlover at hotmail dot com 2014-05-16 15:08 ` jakub at gcc dot gnu.org [this message] 2014-10-03 7:30 ` [Bug libgomp/61200] " jakub at gcc dot gnu.org 2014-10-03 8:18 ` jakub at gcc dot gnu.org 2014-10-03 8:24 ` jakub at gcc dot gnu.org 2014-11-28 17:03 ` jakub at gcc dot gnu.org 2014-11-28 17:13 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-61200-4-qHuJULPFgz@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).