From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16647 invoked by alias); 20 Jan 2011 05:58:03 -0000 Received: (qmail 16594 invoked by uid 22791); 20 Jan 2011 05:58:02 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_GJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 20 Jan 2011 05:57:57 +0000 Received: from wpaz21.hot.corp.google.com (wpaz21.hot.corp.google.com [172.24.198.85]) by smtp-out.google.com with ESMTP id p0K5vtJE023799 for ; Wed, 19 Jan 2011 21:57:56 -0800 Received: from qwi2 (qwi2.prod.google.com [10.241.195.2]) by wpaz21.hot.corp.google.com with ESMTP id p0K5vsJ9006885 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Wed, 19 Jan 2011 21:57:54 -0800 Received: by qwi2 with SMTP id 2so221777qwi.6 for ; Wed, 19 Jan 2011 21:57:54 -0800 (PST) Received: by 10.224.2.206 with SMTP id 14mr1515331qak.78.1295503074462; Wed, 19 Jan 2011 21:57:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.29.204 with HTTP; Wed, 19 Jan 2011 21:57:24 -0800 (PST) In-Reply-To: <201101191409.17445.pedro@codesourcery.com> References: <20110119204315.0A235190C48@elbrus2.mtv.corp.google.com> <201101191409.17445.pedro@codesourcery.com> From: Paul Pluzhnikov Date: Thu, 20 Jan 2011 07:17:00 -0000 Message-ID: Subject: Re: [patch] Fix leak of bp_jit_event breakpoints To: Pedro Alves Cc: gdb-patches@sourceware.org, Yao Qi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-01/txt/msg00425.txt.bz2 On Wed, Jan 19, 2011 at 1:09 PM, Pedro Alves wrote: > On Wednesday 19 January 2011 13:43:15, Paul Pluzhnikov wrote: >> @@ -10588,11 +10588,12 @@ breakpoint_re_set_one (void *bint) >> =A0 =A0 =A0 =A0printf_filtered (_("Deleting unknown breakpoint type %d\n= "), >> b->type); /* fall through */ >> =A0 =A0 =A0 =A0/* Delete overlay event and longjmp master breakpoints; t= hey will be >> - =A0 =A0 =A0 =A0reset later by breakpoint_re_set. =A0*/ >> + =A0 =A0 =A0 =A0reset later by breakpoint_re_set. =A0Likewise for jit_e= vent. =A0*/ >> =A0 =A0 =A0case bp_overlay_event: >> =A0 =A0 =A0case bp_longjmp_master: >> =A0 =A0 =A0case bp_std_terminate_master: >> =A0 =A0 =A0case bp_exception_master: >> + =A0 =A0case bp_jit_event: >> =A0 =A0 =A0 =A0delete_breakpoint (b); >> =A0 =A0 =A0 =A0break; >> >> @@ -10619,7 +10620,6 @@ breakpoint_re_set_one (void *bint) >> =A0 =A0 =A0case bp_longjmp_resume: >> =A0 =A0 =A0case bp_exception: >> =A0 =A0 =A0case bp_exception_resume: >> - =A0 =A0case bp_jit_event: >> =A0 =A0 =A0 =A0break; >> =A0 =A0 =A0} > > This part doesn't look quite right. =A0In non-stop (breakpoint always-ins= erted) > mode, this looks it will create a race window where you delete the jit ev= ent > breakpoint whenever a random thread loads/unloads a DSO, meaning > you could miss a jit registration done by some other thread still running. Good point. We could go with Yao's solution of searching for a matching existing bp_jit_event at the given address; but I don't like it for two reasons: - yet another linear loop - if a binary is reloaded, and &__jit_debug_register_code changes, we'll still leak a breakpoint on rerun Would recording the current jit_event breakpoint in inferior (via register_inferior_data_with_cleanup ()) be a good solution? Thanks, --=20 Paul Pluzhnikov