From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id 6C0A53983052 for ; Thu, 15 Jul 2021 13:26:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C0A53983052 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="197810203" X-IronPort-AV: E=Sophos;i="5.84,242,1620716400"; d="scan'208";a="197810203" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2021 06:26:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,242,1620716400"; d="scan'208";a="413646046" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga003.jf.intel.com with ESMTP; 15 Jul 2021 06:26:50 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Thu, 15 Jul 2021 06:26:50 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Thu, 15 Jul 2021 06:26:49 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Thu, 15 Jul 2021 06:26:49 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.41) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.10; Thu, 15 Jul 2021 06:26:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kSwk9bGi/aNkia8G7GNxqxqUOrojBsn/Ybej/i372arKaoqPdgcXosg02fSSaS3Juz+uEmBq6fl6IPTMwtupIgUO27WrwKat8UoOE9ml74PGc4YzIqNnd+Bf9Mr5A57vCL7IQi7qI5uuyU6285ozyRE2061y1Ce/qxkBFtYopLrwP8JnXvh/d9HvFEIGeg6MZMsxCMTL9Pa+eHjgvltDLbcy9ac6j+O3q13Nl9X080S9x8cqq7mvGI2Dc1mslRkj4snGIj/Ke7JYgnB2OCPKE6xqGLEU0MubPRYi3a1FlxuBupVW61tIcaB4wPt6Irb6OuxzidGS7nvBZ1nJsw4uhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=atHXsY0ZyD0NPQ6bDOAxFqj1GXI68Y9Rf2yG6jo1k9A=; b=U5UJcAwbdLGWSAGN+DI3Nu68H+tHRA7bkSB5UK+5kXo/f49AIHQViv3S3MtmPqGQruK6i+L/T/4KVcgGZtpuw7H+ztYoSfhHUf/pFimrp2y4JTckcVJvfXRogUEA26B0UHZFF+pqbDKKmYTnDZX9UUsEsObVPKXFlra+ClJNYGEZ6pqsE2aJpBIYjXM1WxlFSw1/hirI33o3/J30ajCWwhwRoD6Hm1ara1f4x/2th7UmpvwZQJIRF823Qb3uxnbBb7m5SplqxllZF9zroPQo/TyhC9Wh8cLaWGsVWWWpcR80piB/fJEEjwHH0swxO6eRUI3M/DhB4XjC7G9+Baj23w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM8PR11MB5749.namprd11.prod.outlook.com (2603:10b6:8:10::15) by DM5PR11MB1338.namprd11.prod.outlook.com (2603:10b6:3:b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Thu, 15 Jul 2021 13:26:46 +0000 Received: from DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::913a:2807:cd70:3a3f]) by DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::913a:2807:cd70:3a3f%7]) with mapi id 15.20.4331.023; Thu, 15 Jul 2021 13:26:46 +0000 From: "Metzger, Markus T" To: Simon Marchi CC: "gdb-patches@sourceware.org" Subject: RE: [PATCH] gdb: set current thread in btrace_compute_ftrace_1 Thread-Topic: [PATCH] gdb: set current thread in btrace_compute_ftrace_1 Thread-Index: AQHXePiYNl9pXh0KS0e+V5PE6fshtatEB8rQ Date: Thu, 15 Jul 2021 13:26:46 +0000 Message-ID: References: <20210714213744.490264-1-simon.marchi@efficios.com> In-Reply-To: <20210714213744.490264-1-simon.marchi@efficios.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3a180234-9840-4bf3-0989-08d9479431e5 x-ms-traffictypediagnostic: DM5PR11MB1338: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: A0ZTahzmoJbtF2NhvYjqoLq99T2tiAlOt+arJO/lfFPUTE3hTc/ZjEWMazIHkncIuFhv/g1yztsgFPbZ5yb585m6xMKqdroxlxGMpn3/rO+uN2Ftjt0pQANzOnRz5F9x9hfR7lBPLTtjkRNMCmE66LXJYg/MTYbNY7/ek2uE3FR/LtyM5jvsXiT9ttUZESnv3k/QiW+Oqy/qBOAQzeq6kANtyyYGSbFvxmrCQfizPRtPrNscOFUkbd4zvuStLyyTDG3ur9zE/NrydsIL4OW+B04LgPCa9wjeLIgZSpmEVP8UjeHHAR70xjrqnMtpr8CX4rZEASd1q86OqHqGrtqxLi9tf1PJhAu+G5PeooliDbgz2WEeT1uSgJrzY962tJmBN8FfEzsiPoYp4swZ9CT4vVFSo0yooJDdWQWBp1SYid3NyrIXkPE8Dj26zSgob4mplm1qILWdAuG6iH6VtRutFviezgLOoJNF8/j0leBZECBQ8m+DpVxM3HP45QnGOEuHWF6ucfK8dwVuhucz6Oj27r2l2zfdrhf8Y99ZSgq0qKSfemWRFJDyjRJk9CxIAGFJHe83FTlpl0+idzMtS4V4e0tCnpGvScPxTKwBlhiwWH1TO/pdSDaUgcF0Nj2KkTZV2Q5b1YBAqyDaQnBaCCu+wimkdlQ4l8qcziF6SyFyxYVlp3M8dT8AydGZ/DzBWXO3vH2r6IhptwaQIg9TW4vocozOqsQvKMTysIqKKtdeHMJBlp9HII3e70ocmf2X069zJmCVlO+ZrmSTfknDnxGO2viqLMLoXSkNQc0i2xBj/KuhU9iYvLjhz4dVKfvNL+r0Q6THbn7O4Dvvc89L9B9aLq+iGdtDw9aVfdJjRdZjoyk= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM8PR11MB5749.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(136003)(396003)(39860400002)(376002)(366004)(4326008)(55016002)(186003)(9686003)(8936002)(83380400001)(26005)(5660300002)(316002)(30864003)(6916009)(2906002)(8676002)(86362001)(66946007)(38100700002)(64756008)(66556008)(66476007)(66446008)(7696005)(966005)(122000001)(76116006)(6506007)(478600001)(52536014)(33656002)(71200400001)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?67s7aj9GeJa1DdM/vOCwqtBCTdXooDEPmXSafNpnhkimh/KHh9qyFj9i1RS1?= =?us-ascii?Q?7ASfg57Do8DDAflKecFibcEAlUja8rG7VOcq+CTNZXQ7xqs7a2bysalZHc9r?= =?us-ascii?Q?Go46pQQ0lvvbg+W5yEFkDIhzJQy0hSj+/iZ/ut9Q4Ak9IUBPfBodt430NHCf?= =?us-ascii?Q?3bvv8NgPC/lGQAVhJfuE6Y8V+SRkwHcbxuJmv+mOuqS6rPnpqT085iSGiWbV?= =?us-ascii?Q?LVyD+YLlOs0NjqLbsgNUMvuk0vwXFgnklx6iPfTAP/ZtnSRkL3IGWOy1J1Th?= =?us-ascii?Q?GU2ITDuCDXJHMgK+LBpWdpZGzdOhHZF0RB9AHhcFNblg7F9CgvWHR4o2wBoN?= =?us-ascii?Q?dTNiqUd8lz/X+zIXjmBM17bG9UJ3ru7xjxk9oZWzqmOQBKWrvFW4ys7wZtP0?= =?us-ascii?Q?25a3BsAQdiPIpbkGsnbM4N1a2V7NFe4i8SkunX7qDAHZ2yGovPzOpARId5WX?= =?us-ascii?Q?0Gl5hYVmVggQL8UqasfILPbCwMuaOGFIniTeTEcJBnV1UR+YHV4XZjJV6ZHY?= =?us-ascii?Q?t+1zmoy2BCM/m0YHJ7dZ1p2BTdDfO1qHL87Ukn77HYyDUqR66Q1qHO1MuMJw?= =?us-ascii?Q?NBORKOmLyz5vaD3NegvM/8d2OC89r/eeBvNo0npf+oCdwP1cZsXbjTnJqHU7?= =?us-ascii?Q?H1etg41CKEJ1mx2+DZxIllmoLfDG//8zbwwAJTYY5GP/S5P0x5IA/yYg3bpW?= =?us-ascii?Q?LfpzfNn3UIMm1TX6c+xAJJbOXepsvHQLf+FvxuwOFwhSD077jsp6tImoMn/t?= =?us-ascii?Q?PK001knrR0EKRZQAuA2lbRKPgqbUwkBfNgqUYMzNj2Dy99aS1Qh4rBvwSnLt?= =?us-ascii?Q?HL1VHGZSsaFoJIY3DNcKRHdi+NaVOxaUQKke9gkFrnvPvRAHouj4J+3gxmMv?= =?us-ascii?Q?+R78POLm4/jUnW3rpnT6iHZ21y3h55yWCXGz/giSIiS1NOXhpAkwpVTWn3iy?= =?us-ascii?Q?c5u1CWx0hSVuBl/70CU/6bJlIUyHPLsALwxIklBcuBCR6pFdXW/D+Ffpgmo1?= =?us-ascii?Q?VuGbUofLoZ7FK5VkmQ5zv06Og3EZfaz/oui6x0f8FVi0UxxZQPJ1mskIoDMY?= =?us-ascii?Q?Q3e33BRktsiqeENMTmoZ9IfNXjxKUS2Csx6sl4lWcFx02FUzSnCIoWOx3F3S?= =?us-ascii?Q?QbpicGEfjl8sRh/SG9HzMhZp73wogfBzllmLmwcvjW6/7R5hZjrxnOAmwxQX?= =?us-ascii?Q?BWMkrYQtgL7A8cGd7Lz2UZvhMLZgIFn9N29vybJsw8ofpy5lWMGU6pdPRwPv?= =?us-ascii?Q?I35UcMvLgInS3mCa2/+/dopboObwhZ4JYDeFj9SWtghVB637JTluaMqbACEJ?= =?us-ascii?Q?z50=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5749.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a180234-9840-4bf3-0989-08d9479431e5 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jul 2021 13:26:46.6326 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VOJ+VxeQe3mprpA1Mg0yW3cfZjYwcbT1OO315OwV8W60xe5l9bYP4rVFhogTjouCgJ0j2bFQkERCPgAU1+vMpxREUcjR50XSYRBqaO+w9/I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1338 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, TXREP, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2021 13:27:12 -0000 Hello Simon, > (gdb) record btrace^M > (gdb) PASS: gdb.btrace/enable-new-thread.exp: record btrace > break 24^M > Breakpoint 2 at 0x555555555175: file /home/smarchi/src/binutils- >gdb/gdb/testsuite/gdb.btrace/enable-new-thread.c, line 24.^M > (gdb) continue^M > Continuing.^M > /home/smarchi/src/binutils-gdb/gdb/inferior.c:303: internal-error: inf= erior* >find_inferior_pid(process_stratum_target*, int): Assertion `pid !=3D 0' fa= iled.^M > A problem internal to GDB has been detected,^M > further debugging may prove unreliable.^M > Quit this debugging session? (y or n) FAIL: gdb.btrace/enable-new-thre= ad.exp: >continue to breakpoint: cont to bp.1 (GDB internal error) > >Note that I only see the failure if GDB is compiled without libipt >support. I presume that this makes it use BTS instead of PT, so >exercises different code paths. Could we arrange the btrace tests to be >ran with both BTS and PT, to cover more code paths in a single >configuration? We run those tests on different boxes with and without PT support. It suff= ices if PT is not available for GDB to fall back to BTS; you don't need a separa= te build. It shouldn't be too hard to run them in a loop over 'pt' and 'bts' and test= both configurations in a single run, if available. I can send patches, but not = immediately. >I think that the commit above just exposed an existing problem. The >stack trace of the internal error is: > > #8 0x0000561cb81e404e in internal_error (file=3D0x561cb83aa2f8 >"/home/smarchi/src/binutils-gdb/gdb/inferior.c", line=3D303, fmt=3D0x561cb= 83aa099 >"%s: Assertion `%s' failed.") at /home/smarchi/src/binutils- >gdb/gdbsupport/errors.cc:55 > #9 0x0000561cb7b5c031 in find_inferior_pid (targ=3D0x561cb8aafb60 >, pid=3D0) at /home/smarchi/src/binutils- >gdb/gdb/inferior.c:303 > #10 0x0000561cb7b5c102 in find_inferior_ptid (targ=3D0x561cb8aafb60 >, ptid=3D...) at /home/smarchi/src/binutils- >gdb/gdb/inferior.c:317 > #11 0x0000561cb7f1d1c3 in find_thread_ptid (targ=3D0x561cb8aafb60 >, ptid=3D...) at /home/smarchi/src/binutils- >gdb/gdb/thread.c:487 > #12 0x0000561cb7f1b921 in >all_matching_threads_iterator::all_matching_threads_iterator >(this=3D0x7ffc4ee34678, filter_target=3D0x561cb8aafb60 >, filter_ptid=3D...) at /home/smarchi/src/binu= tils- >gdb/gdb/thread-iter.c:125 > #13 0x0000561cb77bc462 in filtered_iteratornon_exited_thread_filter>::filtered_iteratorptid_t const&> (this=3D0x7ffc4ee34670) at /home/smarchi/src/binutils- >gdb/gdb/../gdbsupport/filtered-iterator.h:42 > #14 0x0000561cb77b97cb in all_non_exited_threads_range::begin >(this=3D0x7ffc4ee34650) at /home/smarchi/src/binutils-gdb/gdb/thread-iter.= h:243 > #15 0x0000561cb7d8ba30 in record_btrace_target::record_is_replaying >(this=3D0x561cb8aa6250 , ptid=3D...) at >/home/smarchi/src/binutils-gdb/gdb/record-btrace.c:1411 > #16 0x0000561cb7d8bb83 in record_btrace_target::xfer_partial >(this=3D0x561cb8aa6250 , object=3DTARGET_OBJECT_MEMORY, >annex=3D0x0, readbuf=3D0x7ffc4ee34c58 "\260g\343N\374\177", writebuf=3D0x0, >offset=3D140737352774277, len=3D1, xfered_len=3D0x7ffc4ee34ad8) at >/home/smarchi/src/binutils-gdb/gdb/record-btrace.c:1437 > #17 0x0000561cb7ef73a9 in raw_memory_xfer_partial (ops=3D0x561cb8aa6250 >, readbuf=3D0x7ffc4ee34c58 "\260g\343N\374\177", >writebuf=3D0x0, memaddr=3D140737352774277, len=3D1, xfered_len=3D0x7ffc4ee= 34ad8) at >/home/smarchi/src/binutils-gdb/gdb/target.c:1504 > #18 0x0000561cb7ef77da in memory_xfer_partial_1 (ops=3D0x561cb8aa6250 >, object=3DTARGET_OBJECT_CODE_MEMORY, >readbuf=3D0x7ffc4ee34c58 "\260g\343N\374\177", writebuf=3D0x0, >memaddr=3D140737352774277, len=3D1, xfered_len=3D0x7ffc4ee34ad8) at >/home/smarchi/src/binutils-gdb/gdb/target.c:1635 > #19 0x0000561cb7ef78b5 in memory_xfer_partial (ops=3D0x561cb8aa6250 >, object=3DTARGET_OBJECT_CODE_MEMORY, >readbuf=3D0x7ffc4ee34c58 "\260g\343N\374\177", writebuf=3D0x0, >memaddr=3D140737352774277, len=3D1, xfered_len=3D0x7ffc4ee34ad8) at >/home/smarchi/src/binutils-gdb/gdb/target.c:1664 > #20 0x0000561cb7ef7ba4 in target_xfer_partial (ops=3D0x561cb8aa6250 >, object=3DTARGET_OBJECT_CODE_MEMORY, annex=3D0x0, >readbuf=3D0x7ffc4ee34c58 "\260g\343N\374\177", writebuf=3D0x0, >offset=3D140737352774277, len=3D1, xfered_len=3D0x7ffc4ee34ad8) at >/home/smarchi/src/binutils-gdb/gdb/target.c:1721 > #21 0x0000561cb7ef8503 in target_read_partial (ops=3D0x561cb8aa6250 >, object=3DTARGET_OBJECT_CODE_MEMORY, annex=3D0x0, >buf=3D0x7ffc4ee34c58 "\260g\343N\374\177", offset=3D140737352774277, len= =3D1, >xfered_len=3D0x7ffc4ee34ad8) at /home/smarchi/src/binutils- >gdb/gdb/target.c:1974 > #22 0x0000561cb7ef861f in target_read (ops=3D0x561cb8aa6250 >, object=3DTARGET_OBJECT_CODE_MEMORY, annex=3D0x0, >buf=3D0x7ffc4ee34c58 "\260g\343N\374\177", offset=3D140737352774277, len= =3D1) at >/home/smarchi/src/binutils-gdb/gdb/target.c:2014 > #23 0x0000561cb7ef809f in target_read_code (memaddr=3D140737352774277, >myaddr=3D0x7ffc4ee34c58 "\260g\343N\374\177", len=3D1) at >/home/smarchi/src/binutils-gdb/gdb/target.c:1869 > #24 0x0000561cb7937f4d in gdb_disassembler::dis_asm_read_memory >(memaddr=3D140737352774277, myaddr=3D0x7ffc4ee34c58 "\260g\343N\374\177", >len=3D1, info=3D0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/gdb/disa= sm.c:139 > #25 0x0000561cb80ab66d in fetch_data (info=3D0x7ffc4ee34e88, >addr=3D0x7ffc4ee34c59 "g\343N\374\177") at /home/smarchi/src/binutils- >gdb/opcodes/i386-dis.c:194 > #26 0x0000561cb80ab7e2 in ckprefix () at /home/smarchi/src/binutils- >gdb/opcodes/i386-dis.c:8628 > #27 0x0000561cb80adbd8 in print_insn (pc=3D140737352774277, >info=3D0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/opcodes/i386-dis.= c:9587 > #28 0x0000561cb80abe4f in print_insn_i386 (pc=3D140737352774277, >info=3D0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/opcodes/i386-dis.= c:8894 > #29 0x0000561cb7744a19 in default_print_insn (memaddr=3D14073735277427= 7, >info=3D0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/gdb/arch-utils.c:= 1029 > #30 0x0000561cb7b33067 in i386_print_insn (pc=3D140737352774277, >info=3D0x7ffc4ee34e88) at /home/smarchi/src/binutils-gdb/gdb/i386-tdep.c:4= 013 > #31 0x0000561cb7acd8f4 in gdbarch_print_insn (gdbarch=3D0x561cbae2fb60, >vma=3D140737352774277, info=3D0x7ffc4ee34e88) at /home/smarchi/src/binutil= s- >gdb/gdb/gdbarch.c:3478 > #32 0x0000561cb793a32d in gdb_disassembler::print_insn >(this=3D0x7ffc4ee34e80, memaddr=3D140737352774277, branch_delay_insns=3D0x= 0) at >/home/smarchi/src/binutils-gdb/gdb/disasm.c:795 > #33 0x0000561cb793a5b0 in gdb_print_insn (gdbarch=3D0x561cbae2fb60, >memaddr=3D140737352774277, stream=3D0x561cb8ac99f8 , >branch_delay_insns=3D0x0) at /home/smarchi/src/binutils-gdb/gdb/disasm.c:8= 50 > #34 0x0000561cb793a631 in gdb_insn_length (gdbarch=3D0x561cbae2fb60, >addr=3D140737352774277) at /home/smarchi/src/binutils-gdb/gdb/disasm.c:859 > #35 0x0000561cb77f53f4 in btrace_compute_ftrace_bts (tp=3D0x561cbba112= 10, >btrace=3D0x7ffc4ee35188, gaps=3D...) at /home/smarchi/src/binutils- >gdb/gdb/btrace.c:1107 > #36 0x0000561cb77f55f5 in btrace_compute_ftrace_1 (tp=3D0x561cbba11210, >btrace=3D0x7ffc4ee35180, cpu=3D0x0, gaps=3D...) at /home/smarchi/src/binut= ils- >gdb/gdb/btrace.c:1527 > #37 0x0000561cb77f5705 in btrace_compute_ftrace (tp=3D0x561cbba11210, >btrace=3D0x7ffc4ee35180, cpu=3D0x0) at /home/smarchi/src/binutils- >gdb/gdb/btrace.c:1560 > #38 0x0000561cb77f583b in btrace_add_pc (tp=3D0x561cbba11210) at >/home/smarchi/src/binutils-gdb/gdb/btrace.c:1589 > #39 0x0000561cb77f5a86 in btrace_enable (tp=3D0x561cbba11210, >conf=3D0x561cb8ac6878 ) at /home/smarchi/src/binutils- >gdb/gdb/btrace.c:1629 > #40 0x0000561cb7d88d26 in record_btrace_enable_warn (tp=3D0x561cbba112= 10) >at /home/smarchi/src/binutils-gdb/gdb/record-btrace.c:294 > #41 0x0000561cb7c603dc in std::__invoke_implthread_info*> (__f=3D@0x561cbb6c4878: 0x561cb7d88cdc >) at >/usr/include/c++/10/bits/invoke.h:60 > #42 0x0000561cb7c5e5a6 in std::__invoke_rthread_info*> (__fn=3D@0x561cbb6c4878: 0x561cb7d88cdc >) at >/usr/include/c++/10/bits/invoke.h:153 > #43 0x0000561cb7c5dc92 in std::_Function_handler(*)(thread_info*)>::_M_invoke(std::_Any_data const&, thread_info*&&) >(__functor=3D..., __args#0=3D@0x7ffc4ee35310: 0x561cbba11210) at >/usr/include/c++/10/bits/std_function.h:291 > #44 0x0000561cb7f2600f in std::function(thread_info*)>::operator()(thread_info*) const (this=3D0x561cbb6c4878, >__args#0=3D0x561cbba11210) at /usr/include/c++/10/bits/std_function.h:622 > #45 0x0000561cb7f23dc8 in gdb::observers::observable::no= tify >(this=3D0x561cb8ac5aa0 , args#0=3D0x561cbba112= 10) at >/home/smarchi/src/binutils-gdb/gdb/../gdbsupport/observable.h:150 > #46 0x0000561cb7f1c436 in add_thread_silent (targ=3D0x561cb8aafb60 >, ptid=3D...) at /home/smarchi/src/binutils- >gdb/gdb/thread.c:263 > #47 0x0000561cb7f1c479 in add_thread_with_info (targ=3D0x561cb8aafb60 >, ptid=3D..., priv=3D0x561cbb3f7ab0) at >/home/smarchi/src/binutils-gdb/gdb/thread.c:272 > #48 0x0000561cb7bfa1d0 in record_thread (info=3D0x561cbb0413a0, tp=3D0= x0, >ptid=3D..., th_p=3D0x7ffc4ee35610, ti_p=3D0x7ffc4ee35620) at >/home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:1380 > #49 0x0000561cb7bf7a2a in thread_from_lwp (stopped=3D0x561cba81db20, >ptid=3D...) at /home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:429 > #50 0x0000561cb7bf7ac5 in thread_db_notice_clone (parent=3D..., child= =3D...) at >/home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:447 > #51 0x0000561cb7bdc9a2 in linux_handle_extended_wait (lp=3D0x561cbae25= 720, >status=3D4991) at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:1981 > #52 0x0000561cb7bdf0f3 in linux_nat_filter_event (lwpid=3D435403, >status=3D198015) at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:2920 > #53 0x0000561cb7bdfed6 in linux_nat_wait_1 (ptid=3D..., >ourstatus=3D0x7ffc4ee36398, target_options=3D...) at /home/smarchi/src/bin= utils- >gdb/gdb/linux-nat.c:3202 > #54 0x0000561cb7be0b68 in linux_nat_target::wait (this=3D0x561cb8aafb60 >, ptid=3D..., ourstatus=3D0x7ffc4ee36398, >target_options=3D...) at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:34= 40 > #55 0x0000561cb7bfa2fc in thread_db_target::wait (this=3D0x561cb8a9acd0 >, ptid=3D..., ourstatus=3D0x7ffc4ee36398, options=3D= ...) at >/home/smarchi/src/binutils-gdb/gdb/linux-thread-db.c:1412 > #56 0x0000561cb7d8e356 in record_btrace_target::wait (this=3D0x561cb8a= a6250 >, ptid=3D..., status=3D0x7ffc4ee36398, options=3D...) at >/home/smarchi/src/binutils-gdb/gdb/record-btrace.c:2547 > #57 0x0000561cb7ef996d in target_wait (ptid=3D..., status=3D0x7ffc4ee3= 6398, >options=3D...) at /home/smarchi/src/binutils-gdb/gdb/target.c:2608 > #58 0x0000561cb7b6d297 in do_target_wait_1 (inf=3D0x561cba6d8780, ptid= =3D..., >status=3D0x7ffc4ee36398, options=3D...) at /home/smarchi/src/binutils- >gdb/gdb/infrun.c:3640 > #59 0x0000561cb7b6d43e in operator() (__closure=3D0x7ffc4ee36190, >inf=3D0x561cba6d8780) at /home/smarchi/src/binutils-gdb/gdb/infrun.c:3701 > #60 0x0000561cb7b6d7b2 in do_target_wait (ecs=3D0x7ffc4ee36370, option= s=3D...) >at /home/smarchi/src/binutils-gdb/gdb/infrun.c:3720 > #61 0x0000561cb7b6e67d in fetch_inferior_event () at >/home/smarchi/src/binutils-gdb/gdb/infrun.c:4069 > #62 0x0000561cb7b4659b in inferior_event_handler >(event_type=3DINF_REG_EVENT) at /home/smarchi/src/binutils-gdb/gdb/inf- >loop.c:41 > #63 0x0000561cb7be25f7 in handle_target_event (error=3D0, client_data= =3D0x0) at >/home/smarchi/src/binutils-gdb/gdb/linux-nat.c:4227 > #64 0x0000561cb81e4ee2 in handle_file_event (file_ptr=3D0x561cbae24e10, >ready_mask=3D1) at /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc= :575 > #65 0x0000561cb81e5490 in gdb_wait_for_event (block=3D0) at >/home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:701 > #66 0x0000561cb81e41be in gdb_do_one_event () at >/home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:212 > #67 0x0000561cb7c18096 in start_event_loop () at /home/smarchi/src/bin= utils- >gdb/gdb/main.c:421 > #68 0x0000561cb7c181e0 in captured_command_loop () at >/home/smarchi/src/binutils-gdb/gdb/main.c:481 > #69 0x0000561cb7c19d7e in captured_main (data=3D0x7ffc4ee366a0) at >/home/smarchi/src/binutils-gdb/gdb/main.c:1353 > #70 0x0000561cb7c19df0 in gdb_main (args=3D0x7ffc4ee366a0) at >/home/smarchi/src/binutils-gdb/gdb/main.c:1368 > #71 0x0000561cb7693186 in main (argc=3D11, argv=3D0x7ffc4ee367b8) at >/home/smarchi/src/binutils-gdb/gdb/gdb.c:32 > >At frame 45, the new_thread observable is fired. At this moment, the >new thread isn't the current thread, inferior_ptid is null_ptid. I >think this is ok: the new_thread observable doesn't give any guarantee >on the global context when observers are invoked. Frame 35, >btrace_compute_ftrace_bts, calls gdb_insn_length. gdb_insn_length >doesn't have a thread_info or other parameter what could indicate where >to read memory from, it implicitly uses the global context >(inferior_ptid). > >So we reach the all_non_exited_threads_range in >record_btrace_target::record_is_replaying with a null inferior_ptid. >The previous implemention of all_non_exited_threads_range didn't care, >but the new one does. The problem of calling gdb_insn_length and >ultimately trying to read memory with a null inferior_ptid already >existed, but the commit mentioned above made it visible. > >Something between frames 40 (record_btrace_enable_warn) and 35 >(btrace_compute_ftrace_bts) needs to be switching the global context to >make TP the current thread. By inspection, it looks like >btrace_compute_ftrace_pt may also call functions sensitive to the global >context: it installs the btrace_pt_readmem_callback callback in the PT >instruction decoder. When this function gets called, inferior_ptid must >be set appropriately. So it has the same potential problem. > >I think that a reasonable place to switch the thread is in >btrace_compute_ftrace_1 (this is what this patch implements) although it >would be fine to do it separately in btrace_compute_ftrace_bts and >btrace_compute_ftrace_pt as well. > >Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28086 >Change-Id: I407fbfe41aab990068bd102491aa3709b0a034b3 >--- > gdb/btrace.c | 6 ++++++ > 1 file changed, 6 insertions(+) > >diff --git a/gdb/btrace.c b/gdb/btrace.c >index 5e689c11d4bd..9dd6f1dc9e94 100644 >--- a/gdb/btrace.c >+++ b/gdb/btrace.c >@@ -1518,6 +1518,12 @@ btrace_compute_ftrace_1 (struct thread_info *tp, > { > DEBUG ("compute ftrace"); > >+ /* btrace_compute_ftrace_bts and btrace_compute_ftrace_pt may end up >doing >+ target calls that require the current thread to be TP, for example to= read >+ memory. Make sure TP is the current thread. */ >+ scoped_restore_current_thread restore_thread; >+ switch_to_thread (tp); >+ > switch (btrace->format) > { > case BTRACE_FORMAT_NONE: >-- >2.26.2 I see a lot of those switch-to-thread and restore-current-thread sprinkled = all over GDB. I counted close to 200 switch_to_.*thread.* using grep. It is not clear to me who is responsible for establishing the global state = and who may assume that the global state has already been setup. This patch apparently fixes an issue but the choice to put the switch-to-th= read here seems arbitrary to me. Regards, Markus. Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928