From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16247 invoked by alias); 29 Sep 2014 21:22:56 -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 16195 invoked by uid 55); 29 Sep 2014 21:22:51 -0000 From: "fdumont at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/62313] Data race in debug iterators Date: Mon, 29 Sep 2014 21:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fdumont at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: fdumont at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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-SW-Source: 2014-09/txt/msg02721.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D62313 --- Comment #12 from Fran=C3=A7ois Dumont --- Author: fdumont Date: Mon Sep 29 21:22:17 2014 New Revision: 215693 URL: https://gcc.gnu.org/viewcvs?rev=3D215693&root=3Dgcc&view=3Drev Log: 2014-09-29 Fran=C3=A7ois Dumont PR libstdc++/62313 * include/debug/safe_base.h (_Safe_iterator_base(const _Safe_iterator_base&)): Delete declaration. (_Safe_iterator_base& operator=3D(const _Safe_iterator_base&)): Likewis= e. * include/debug/safe_iterator.h (_Safe_iterator<>): Move normal iterator before _Safe_iterator_base in memory. Lock before modifying the iterator in numerous places. * include/debug/safe_local_iterator.h (_Safe_local_iterator_base(const _Safe_local_iterator_base&)): Delete declaration. (_Safe_local_iterator_base& operator=3D(const _Safe_local_iterator_base= &)): Likewise. * include/debug/safe_unordered_base.h (_Safe_local_iterator<>): Move normal iterator before _Safe_iterator_base in memory. Lock before modifying the iterator in numerous places. * include/debug/forward_list (_Safe_forward_list<>::_M_swap_aux): Adapt. * include/debug/safe_sequence.tcc (_Safe_sequence<>::_M_transfer_from_if): Adapt. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/debug/forward_list trunk/libstdc++-v3/include/debug/safe_base.h trunk/libstdc++-v3/include/debug/safe_iterator.h trunk/libstdc++-v3/include/debug/safe_local_iterator.h trunk/libstdc++-v3/include/debug/safe_sequence.tcc trunk/libstdc++-v3/include/debug/safe_unordered_base.h >>From gcc-bugs-return-462888-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Sep 29 21:26:36 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 21409 invoked by alias); 29 Sep 2014 21:26:36 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 21362 invoked by uid 48); 29 Sep 2014 21:26:33 -0000 From: "fdumont at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/62313] Data race in debug iterators Date: Mon, 29 Sep 2014 21:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fdumont at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: fdumont at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution target_milestone 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-SW-Source: 2014-09/txt/msg02722.txt.bz2 Content-length: 648 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D62313 Fran=C3=A7ois Dumont changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED Target Milestone|--- |5.0 --- Comment #13 from Fran=C3=A7ois Dumont --- A number of additional locks have been added to make sure we do not modify = an iterator while the list of iterators might be checked through another threa= d. >>From gcc-bugs-return-462889-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Sep 29 21:40:15 2014 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 28614 invoked by alias); 29 Sep 2014 21:40:15 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 28576 invoked by uid 48); 29 Sep 2014 21:40:11 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/63411] New: [4.9/5 regression] ivopt produces wrong struct offset Date: Mon, 29 Sep 2014 21:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: critical X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cf_gcchost cf_gcctarget Message-ID: 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-09/txt/msg02723.txt.bz2 Content-length: 2438 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63411 Bug ID: 63411 Summary: [4.9/5 regression] ivopt produces wrong struct offset Product: gcc Version: 5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: critical Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: olegendo at gcc dot gnu.org Host: i686-linux-gnu Target: sh*-*-* Compiling the following as C or C++: typedef struct { unsigned char sprindex; unsigned char y; unsigned char index; unsigned char attr; unsigned char x; unsigned short pattern; } oam; extern oam OAM3[8]; int test2 (unsigned c, int r) { for (unsigned i = 0; i < c; ++i) { oam* s = &(OAM3[i]); if (s->attr & 0x40) r += s->pattern; } return r; } on SH (big or little endian, any CPU type) with -O2 results in the following wrong code: _test2: tst r4,r4 bt .L12 mov.l .L14,r1 .align 2 .L4: mov.b @r1,r0 tst #64,r0 bt/s .L3 mov r1,r2 add #3,r2 <<< wrong struct offset '3' mov.w @r2,r2 <<< should be '3*2', i.e. '6'. extu.w r2,r2 add r2,r5 .L3: dt r4 bf/s .L4 add #8,r1 .L12: rts mov r5,r0 .L15: .align 2 .L14: .long _OAM3+3 .size _test2, .-_test2 .ident "GCC: (GNU) 4.9.2 20140929 (prerelease)" Disabling ivopt with '-fno-ivopts' produces correct code: _test2: tst r4,r4 bt .L12 mov #0,r2 mov.l .L14,r3 .align 2 .L4: mov r2,r1 shll2 r1 add r1,r1 add r3,r1 mov.b @(3,r1),r0 tst #64,r0 bt .L3 mov.w @(6,r1),r0 <<< correct struct offset '6' extu.w r0,r1 add r1,r5 .L3: dt r4 bf/s .L4 add #1,r2 .L12: rts mov r5,r0 .L15: .align 2 .L14: .long _OAM3 .size _test2, .-_test2 .ident "GCC: (GNU) 4.9.2 20140929 (prerelease)" I haven't checked whether this happens on other targets, but I guess this is not SH specific. This happens on the current 4.9 branch and trunk. 4.8 branch is not affected.