From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4C8A03858C2C; Sat, 4 Dec 2021 23:04:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C8A03858C2C From: "hedayat.fwd at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103537] Using -fstack-protector-strong "without" optimization cause segmentation fault Date: Sat, 04 Dec 2021 23:04:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hedayat.fwd at gmail dot com X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: 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: 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: Sat, 04 Dec 2021 23:04:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103537 --- Comment #4 from Hedayat Vatankhah --- Well, sorry if I should gave more logs to make it more clear. Note that the crash happens here: https://github.com/hedayat/powerfake/blob/a4c80d6628816656796d2e85b4422218d= a05ce00/powerfake.h#L257 And the problematic code doesn't use any of the parts of the code you mentioned.=20 To make the scope of the problem much less, I replaced main() function as follows and commented out all other unrelated code: int main() { SampleClass2 sc2; SamplePrivate::Call(sc2); } This code certainly doesn't use any of the code you mentioned. It only uses TAG_PRIVATE_MEMBER macro, which in turn uses TagBase and PrivateFunctionExtractor structs, and no other code.=20 The behavior is as follows: * without -fstack-protector-strong, with or without any of the sanitize opt= ions the code runs normally. No crash, and not any messages from any of the sanitizers. * with -fstack-protector-strong, with or without -fsanitize=3Dundefined, yo= u got a segmentation fault. Logs when running with -fsanitize=3Dundefined: /home/hedayat/Projects/powerfake/powerfake.h:257:40: runtime error: load of misaligned address 0x7f64004083fc for type ' *', which requires 8 = byte alignment 0x7f64004083fc: note: pointer points here zsh: segmentation fault (core dumped) ./sample/samples * with -fstack-protector-strong and with -fsanitize=3Daddress, you don't ge= t a crash, so -fsanitizer=3Daddress somehow fixes the problem caused with -fstack-protector-strong. (Using address sanitizer only causes a crash when= I use OverloadedPrivateFloat::Call(sc2, 5);, which I will investigate. But th= at issue seems completely unrelated to this bug. address sanitizer causes a cr= ash with that function even when -fstack-protector-strong is not used).=