From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 40CB63870891; Mon, 19 Oct 2020 13:42:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40CB63870891 From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/97461] [11 Regression] allocate_gcov_kvp() deadlocks in firefox LTO+PGO build (overridden malloc() recursion) Date: Mon, 19 Oct 2020 13:42:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 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: Mon, 19 Oct 2020 13:42:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97461 --- Comment #6 from Martin Li=C5=A1ka --- (In reply to Richard Biener from comment #5) > Hmm, is the TOPN allocation strathegy configurable? I wonder whether we = have > to resort to an alternate allocation scheme (mmap/sbrk), avoiding libc? No. The only thing we support is a recursive malloc as seen in: ./gcc/testsuite/gcc.dg/tree-prof/indir-call-prof-malloc.c It was added in g:bc2b1a232b1825b421a1aaa21a0865b2d1e4e08c as we use a statically allocated buffer when we recursively entry allocate_gcov_kvp. However this is different as we can't call malloc/calloc from the function = as we're in code that initializes a memory allocator. We can mitigate the issue with a pair of new functions __gcov_supress_malloc and __gcov_alloc_malloc that will be called by a custom memory allocator. What do you think about it? > At > least > I don't see a good way to force the gcov allocation to call the libc mall= oc > rather than a user replacement that is being instrumented. Of course the > instrumentation code could do sth like >=20 > if (is_allocated =3D=3D 0) > { > is_allocated =3D in_progress; > ... =3D malloc (); > is_allocated =3D 1; > } > else if (is_allocted =3D=3D in_progress) > { > topn_mem =3D &transitional_garbage_space; > } >=20 > but of course that's quite some overhead for a small benefit. Maybe it > could be hidden in gcov_malloc.=