From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E9CC2388882A; Tue, 10 May 2022 08:24:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9CC2388882A From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/102656] [11 Regression] ICE on coroutines on -fsanitize=address -O1 since r11-1613-g788b962aa00959e8 Date: Tue, 10 May 2022 08:24:29 +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: 11.2.1 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.3 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: Tue, 10 May 2022 08:24:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102656 --- Comment #9 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:f2549d3bc752bf832ca6de9830ff50b3f23143ab commit r10-10686-gf2549d3bc752bf832ca6de9830ff50b3f23143ab Author: Jakub Jelinek Date: Sat Feb 19 09:03:57 2022 +0100 asan: Mark instrumented vars addressable [PR102656] We ICE on the following testcase, because the asan1 pass decides to instrument .x =3D 0; and does that by _13 =3D &.x; .ASAN_CHECK (7, _13, 4, 4); .x =3D 0; and later sanopt pass turns that into: _39 =3D (unsigned long) &.x; _40 =3D _39 >> 3; _41 =3D _40 + 2147450880; _42 =3D (signed char *) _41; _43 =3D *_42; _44 =3D _43 !=3D 0; _45 =3D _39 & 7; _46 =3D (signed char) _45; _47 =3D _46 + 3; _48 =3D _47 >=3D _43; _49 =3D _44 & _48; if (_49 !=3D 0) goto ; [0.05%] else goto ; [99.95%] [local count: 536864]: __builtin___asan_report_store4 (_39); [local count: 1073741824]: .x =3D 0; The problem is during expansion, isn't marked TREE_ADDRESSABLE, even when we take its address in (unsigned long) &.x. Now, instrument_derefs has code to avoid the instrumentation altogether if we can prove the access is within bounds of an automatic variable in= the current function and the var isn't TREE_ADDRESSABLE (or we don't instru= ment use after scope), but we do it solely for VAR_DECLs. I think we should treat RESULT_DECLs exactly like that too, which is wh= at the following patch does. I must say I'm unsure about PARM_DECLs, those can have different cases, either they are fully or partially passed in registers, then if we take parameter's address, they are in a local copy inside of a function and so work like those automatic vars. But if they are fully passed in memory, we typically just take address of the slot and in that case they live in the caller's frame. It is true we don't (can't) put any asan padding in between the arguments, so all asan could detect in that case is if caller passes fewer on stack arguments or sma= ller arguments than callee accepts. Anyway, as I'm unsure, I haven't added PARM_DECLs to that case. And another thing is, when we actually build_fold_addr_expr, we need to mark_addressable the inner if it isn't addressable already. 2022-02-19 Jakub Jelinek PR sanitizer/102656 * asan.c (instrument_derefs): If inner is a RESULT_DECL and acc= ess is known to be within bounds, treat it like automatic variables. If instrumenting access and inner is {VAR,PARM,RESULT}_DECL from current function and !TREE_STATIC which is not TREE_ADDRESSABLE, mark it addressable. (cherry picked from commit 9e3bbb4a8024121eb0fa675cb1f074218c1345a6)=