From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 573F83857033; Fri, 30 Oct 2020 08:45:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 573F83857033 From: "slyfox 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: Fri, 30 Oct 2020 08:45:38 +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: slyfox at gcc dot gnu.org X-Bugzilla-Status: WAITING 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: Fri, 30 Oct 2020 08:45:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97461 --- Comment #19 from Sergei Trofimovich --- (In reply to Martin Li=C5=A1ka from comment #16) > (In reply to Sergei Trofimovich from comment #15) > > allocate_gcov_kvp() gets called 89 times. Tried as: >=20 > All right, it's quite close to what we have. > So can you please test the following patch: >=20 > diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h > index 4e95c7c82ee..a899a02b765 100644 > --- a/gcc/gcov-io.h > +++ b/gcc/gcov-io.h > @@ -293,7 +293,7 @@ GCOV_COUNTERS > #define GCOV_TOPN_MAXIMUM_TRACKED_VALUES 32 >=20=20 > /* Number of pre-allocated gcov_kvp structures. */ > -#define GCOV_PREALLOCATED_KVP 64 > +#define GCOV_PREALLOCATED_KVP 128 >=20=20 > /* Convert a counter index to a tag. */ > #define GCOV_TAG_FOR_COUNTER(COUNT) \ Still hangs somewhere in the middle of firefox inners: (gdb) bt #0 __lll_lock_wait (futex=3D0x7f03a8900018, private=3D0) at lowlevellock.c= :52 #1 0x00007f03a9097305 in __GI___pthread_mutex_lock (mutex=3D0x7f03a8900018= ) at ../nptl/pthread_mutex_lock.c:135 #2 0x0000556eee199141 in arena_t::MallocSmall(unsigned long, bool) () #3 0x0000556eee19a06c in arena_t::Malloc(unsigned long, bool) () #4 0x0000556eee19b1e2 in calloc () #5 0x0000556eee28ba2b in allocate_gcov_kvp () at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov.h:431 #6 gcov_topn_add_value (count=3D1, use_atomic=3D1, increment_total=3D1, va= lue=3D480, counters=3D0x556eee2fc8c0 <__gcov3._ZL20arena_run_reg_dallocP11arena_run_tP11arena_bin_tPvm>) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov.h:477 #7 __gcov_topn_values_profiler_body (use_atomic=3D1, value=3D480, counters=3D0x556eee2fc8c0 <__gcov3._ZL20arena_run_reg_dallocP11arena_run_tP11arena_bin_tPvm>) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-profiler.c:103 #8 __gcov_topn_values_profiler_atomic (counters=3D0x556eee2fc8c0 <__gcov3._ZL20arena_run_reg_dallocP11arena_run_tP11arena_bin_tPvm>, value= =3D480) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-profiler.c:128 #9 0x0000556eee198055 in arena_t::DallocSmall(arena_chunk_t*, void*, arena_chunk_map_t*) () #10 0x0000556eee19865c in free () #11 0x00007f03a8ca5bff in _IO_deallocate_file (fp=3D0x7f0372220b60) at libioP.h:863 #12 _IO_new_fclose (fp=3D0x7f0372220b60) at iofclose.c:74 #13 0x00007f039dbd5b62 in __gcov_close () at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/../gcc/gcov-io.c:212 #14 0x00007f039dbd62ed in dump_one_gcov (run_max=3D139, run_counted=3D0, gf=3D, gi_ptr=3D0x7f03a3c432e0) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-driver.c:516 #15 gcov_do_dump (list=3D, run_counted=3D0) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-driver.c:555 #16 0x00007f039dbd7152 in __gcov_dump_one (root=3D0x7f03a616b700 <__gcov_ro= ot>) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-driver.c:578 #17 __gcov_dump_one (root=3D0x7f03a616b700 <__gcov_root>) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-driver.c:573 #18 0x00007f039dbd7318 in __gcov_dump_int () at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-interface.c:160 #19 __gcov_dump () at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-interface.c:170 #20 0x00007f039dbd5497 in __gcov_execve (path=3D0x7f036db530b0 "/home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instru= mented/dist/firefox/firefox", argv=3D0x7f0372632a00, envp=3D0x7f036cc8e000) at /var/tmp/portage/sys-devel/gcc-11.0.0_pre9999/work/gcc-11.0.0_pre9999/libgc= c/libgcov-interface.c:343 #21 0x00007f039388b0fb in base::LaunchApp(std::vector, std::allocator >, std::allocator, std::allocator > > > const&, base::LaunchOptions const&, int*) () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #22 0x00007f0393929bac in mozilla::ipc::PosixProcessLauncher::DoLaunch() ()= at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #23 0x00007f039392a35a in mozilla::ipc::BaseProcessLauncher::PerformAsyncLaunch() () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #24 0x00007f0393920296 in mozilla::detail::ProxyRunnable, RefPtr > (mozilla::ipc::BaseProcessLauncher::*)(= ), mozilla::ipc::BaseProcessLauncher>::Run() () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #25 0x00007f0392db38f0 in mozilla::TaskQueue::Runner::Run() () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #26 0x00007f0392d978f5 in nsThread::ProcessNextEvent(bool, bool*) () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #27 0x00007f0392d77130 in NS_ProcessNextEvent(nsIThread*, bool) () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #28 0x00007f03939554cd in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate= *) () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #29 0x00007f0393891ecd in MessageLoop::Run() () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #30 0x00007f0392dbc45a in nsThread::ThreadFunc(void*) () at /home/slyfox/tmp/portage/www-client/firefox-82.0/work/firefox_build/instrum= ented/dist/firefox/libxul.so #31 0x00007f03a8adf880 in _pt_root () at /usr/lib64/libnspr4.so #32 0x00007f03a9094e6e in start_thread (arg=3D0x7f0372755640) at pthread_create.c:463 #33 0x00007f03a8d2ed2f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95=