From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 04E52385843B; Sun, 30 Jan 2022 23:37:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04E52385843B From: "pobrn at protonmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/95137] Sanitizers seem to be missing support for coroutines Date: Sun, 30 Jan 2022 23:37:42 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pobrn at protonmail dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: iains at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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: Sun, 30 Jan 2022 23:37:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95137 Barnab=C3=A1s P=C5=91cze changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pobrn at protonmail dot com --- Comment #46 from Barnab=C3=A1s P=C5=91cze = --- (In reply to stream009 from comment #42) > I got strange compile error when I use coroutine with UBSAN. >=20 > The weird thing is error is reported in compile time not runtime. > The code compile fine without UBSAN. > [...] > =3D=3D=3D begin compile error =3D=3D=3D > : In function 'void _Z5errori.actor(error(int)::_Z5errori.frame*)= ': > :21:9: warning: '' may be used uninitialized > [-Wmaybe-uninitialized] > 21 | co_return; > | ^~~~~~~~~ > :21:9: note: '' was declared here > 21 | co_return; > | ^~~~~~~~~ > =3D=3D=3D end compile error =3D=3D=3D I am not familiar with the internals of gcc at all, but it appears that thi= s is due to incorrect code generation. When ubsan is not used, the generated gim= ple looks like this: if (_13 =3D=3D 0) goto ; else goto ; : _14 =3D &frame_ptr->__p; result::promise_type::return_void (_14); goto final.suspend; : _15 =3D &frame_ptr->__p; result::promise_type::return_void (_15); when ubsan is used, however: if (_8 =3D=3D 0) goto ; else goto ; : D.9938 =3D &frame_ptr->__p; .UBSAN_NULL (D.9938, 4B, 0); result::promise_type::return_void (D.9938); goto final.suspend; : .UBSAN_NULL (D.9938, 4B, 0); result::promise_type::return_void (D.9938); `D.9938` is not initialized, and I guess hence the warning. --- I have noticed that this does not happen on f6f2d6cfec1c2fe9570b98211be58329d8d7749b, so out of curiosity I tried to bi= sect gcc: > git bisect start > # new: [f6f2d6cfec1c2fe9570b98211be58329d8d7749b] Daily bump. > git bisect new f6f2d6cfec1c2fe9570b98211be58329d8d7749b > # old: [7ca388565af176bd4efd4f8db1e5e9e11e98ef45] Update ChangeLog and ve= rsion files for release > git bisect old 7ca388565af176bd4efd4f8db1e5e9e11e98ef45 > # old: [250f234988b6231669a720c52101d3686d645072] testsuite: Fix up gcc.t= arget/s390/zero-scratch-regs-1.c > git bisect old 250f234988b6231669a720c52101d3686d645072 > # old: [79513dc0b2d980bfd1b109d0d502de487c02b894] compiler: don't pad zer= o-sized trailing field in results struct > git bisect old 79513dc0b2d980bfd1b109d0d502de487c02b894 > # new: [1b62cddcf091fb8cadf575246a7d3ff778650a6b] Fix ipa-modref pure/con= st discovery > git bisect new 1b62cddcf091fb8cadf575246a7d3ff778650a6b > # new: [247bac507e63b32d4dc23ef1c55f300aafea24c6] libstdc++: Simplify std= ::basic_regex::assign > git bisect new 247bac507e63b32d4dc23ef1c55f300aafea24c6 > # new: [d5f8abe1d3f718a75cbff0a453c1d961be5939b7] Use on-demand ranges in= ssa_name_has_boolean_range before querying nonzero bits. > git bisect new d5f8abe1d3f718a75cbff0a453c1d961be5939b7 > # new: [7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957] Don't record string con= catenation data for 'RESERVED_LOCATION_P' > git bisect new 7d79c3ebc3f3f6f8aecf83726c97474ae5cfe957 > # new: [8137be3958be4e5421c283cce3e5b50dbb80b84e] mips: Fix macro typo > git bisect new 8137be3958be4e5421c283cce3e5b50dbb80b84e > # old: [caef5203d64e61da506909d58890035af32a6239] Fix internal error on p= ointer-to-pointer binding in LTO mode > git bisect old caef5203d64e61da506909d58890035af32a6239 > # new: [cc1e28878a228b6c4a0872e56d97ac88971b7725] libstdc++: Check for TL= S support on mingw cross-compilers > git bisect new cc1e28878a228b6c4a0872e56d97ac88971b7725 > # new: [70ee703c479081ac2ea67eb67041551216e66783] coroutines: Make proxy = vars for the function arg copies. > git bisect new 70ee703c479081ac2ea67eb67041551216e66783 > # old: [bd55fa102715c7442c050b193dadfdb5337e2377] Fix PR ada/101970 > git bisect old bd55fa102715c7442c050b193dadfdb5337e2377 > # old: [f008fd3a480e3718436156697ebe7eeb47841457] c++: Fix __is_*construc= tible/assignable for templates [PR102305] > git bisect old f008fd3a480e3718436156697ebe7eeb47841457 > # old: [de07cff96abd43f6f65dcf333958899c2ec42598] c++: empty union member= activation during constexpr [PR102163] > git bisect old de07cff96abd43f6f65dcf333958899c2ec42598 > # skip: [c5a735fa9df7eca4666c8da5e51ed9c5ab7cc81a] coroutines: Expose imp= lementation state to the debugger. > git bisect skip c5a735fa9df7eca4666c8da5e51ed9c5ab7cc81a > # only skipped commits left to test > # possible first new commit: [70ee703c479081ac2ea67eb67041551216e66783] c= oroutines: Make proxy vars for the function arg copies. > # possible first new commit: [c5a735fa9df7eca4666c8da5e51ed9c5ab7cc81a] c= oroutines: Expose implementation state to the debugger. Unfortunately, when I got to c5a735fa9df7eca4666c8da5e51ed9c5ab7cc81a, it d= id not build; I am not sure where I had gone wrong: > g++ -std=3Dc++11 -fno-PIE -c -DIN_GCC_FRONTEND -g -DIN_GCC -fno-exc= eptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwr= ite-strings -Wcast-qual -Wno-error=3Dformat-diag -Wno-format -Wmissing-form= at-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-ma= cros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -Icp -I../.././gcc -I../= .././gcc/cp -I../.././gcc/../include -I../.././gcc/../libcpp/include -I../.= ././gcc/../libcody -I../.././gcc/../libdecnumber -I../.././gcc/../libdecnu= mber/bid -I../libdecnumber -I../.././gcc/../libbacktrace -o cp/coroutines= .o -MT cp/coroutines.o -MMD -MP -MF cp/.deps/coroutines.TPo ../.././gcc/cp/= coroutines.cc > ../.././gcc/cp/coroutines.cc: In function =E2=80=98void build_actor_fn(lo= cation_t, tree, tree, tree, tree, hash_map*, ve= c*, tree, unsigned int, tree)=E2=80=99: > ../.././gcc/cp/coroutines.cc:2180:30: error: =E2=80=98param_uses=E2=80=99= was not declared in this scope > 2180 | param_info &parm =3D param_uses->get_or_insert (arg, &e= xisted); > | ^~~~~~~~~~ --- Nonetheless, on 70ee703c479081ac2ea67eb67041551216e66783, the generated gim= ple with ubsan looks like this: if (_13 =3D=3D 0) goto ; else goto ; : _14 =3D &frame_ptr->_Coro_promise; result::promise_type::return_void (_14); goto final.suspend; : _15 =3D &frame_ptr->_Coro_promise; result::promise_type::return_void (_15); Interestingly, even with ubsan, the checks are now gone.=