From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3C1953857C74; Wed, 7 Oct 2020 15:56:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C1953857C74 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/97294] ASAN "dynamic-stack-buffer-overflow" false positive with OpenMP reduction to std::vector Date: Wed, 07 Oct 2020 15:56:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to bug_status attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Oct 2020 15:56:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97294 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gn= u.org Status|NEW |ASSIGNED --- Comment #2 from Jakub Jelinek --- Created attachment 49323 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49323&action=3Dedit gcc11-pr97294.patch Untested fix. Self-contained testcase with -O0 -fsanitize=3Daddress -fopenmp could be e.g. __attribute__((noipa)) void foo (int *p, int n) { int i; #pragma omp parallel for num_threads(2) reduction(+:p[:n]) for (i =3D 0; i < 10; i++) { p[0]++; p[n - 1] +=3D 2; } } __attribute__((noipa)) void bar (void) { unsigned char buf[1024]; int i; asm volatile ("" : : "r" (&buf[0]) : "memory"); for (i =3D 0; i < 1024; i++) buf[i] =3D i; asm volatile ("" : : "r" (&buf[0]) : "memory"); } int main () { int p[50], i; for (i =3D 0; i < 50; i++) p[i] =3D 0; foo (p, 50); bar (); if (p[0] !=3D 10 || p[49] !=3D 20) __builtin_abort (); return 0; } The problem was that nothing set cfun->calls_alloca flag in the child omp function and thus the asan code wouldn't add __asan_allocas_unpoison call at the end of the function. Normally when optimizing, DCE clears those flags = and recomputes them again, so this was only problematic with -O0.=