From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id a5SiCtxa/WVKYREAWB0awg (envelope-from ) for ; Fri, 22 Mar 2024 06:18:04 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=GW9apWAT; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 1B9AE1E0C0; Fri, 22 Mar 2024 06:18:04 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E04C71E030 for ; Fri, 22 Mar 2024 06:18:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5BB25385842A for ; Fri, 22 Mar 2024 10:18:01 +0000 (GMT) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id B8CFC3858403 for ; Fri, 22 Mar 2024 10:17:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8CFC3858403 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B8CFC3858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711102659; cv=none; b=CAGaDUrraOki5Kd/lKlsUtv3RwDsb7LGFX05OUFgHxHzhdaKB2dbO6KthamANMWS7AVDvOaK2gVbYe4GUhbW7fMTSyXwpvsLh3f1UWIobDBn0hmlyMDLH2NJkF9d8HG0lO1QrEq1SkYOMQ258GdvOTO1kHbd7wmOTPfY1Myknlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711102659; c=relaxed/simple; bh=VN/MRAU0eRKwXUJf1gvs0XAsePhWwUfpdUKmGB9xsYk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Wz5aTSx6JgaHl6aVhdOP3oWWc658Q56fZIJdZnbFoMvdrCJGBh95m/5TqDuaNkwhzQaPn0dhXvjP2bhlZq7PO5n+i7qp+3+whf1DwD7OQ9G4n2RUfBMMdahaXtQD27T8sUlDU8OyvQyIXdBh2j2J6jLXowBMNIz6luGPp7Y0mMc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-56bc7b07df7so2845785a12.0 for ; Fri, 22 Mar 2024 03:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711102647; x=1711707447; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RsDYo2ttmNDXjctLIiD+BkFBAQPqDpVx98nhrMpwXAo=; b=GW9apWATaCOvZY+Hpf4uAQB+Plkw615G4tFT8r59KEssRquyTVvZxZFa2qTG9avAQF OAqdiXq3D3O4R5oU3dmmQ5sR+BtGsMTip3BUBXLsGGWe767CeCraYe4/W/mquHfqE/Qy S/Zldo87znvSHhrnph6v2FyapGhVUT0UfHuZVYqUyd8VEahBemcPQ2cdy/dJsZ77AHEm bUqxBoSviWgrIVZLMi522eaxJRx+nVxIQ8kqg2g5dFwwrIjDtvyhqMq6xqKLlZXAAg1+ j+TnCwIRcX6GjqmA4lJHjJpvtw7R5Mzax+cyeOeySuiru24WC8rKcAd5W5gVOl3JjJqF tUCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711102647; x=1711707447; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RsDYo2ttmNDXjctLIiD+BkFBAQPqDpVx98nhrMpwXAo=; b=h+FrgfU73mQzcu550Dw290bNgb+M+SqRvMkbsnyiYiiteFihGFaSFkldzTKBE1Ec0E YUi9AhxBnnM78zppzvFnq2dKkyLdFcRMq2jprmUzZr3t5ys/TtDw+ysFpJYvObhz8Bah vnKjb52estUwj4dzAFeZFK4AEDvZBI0O8IcDP+tHcojOyMxv1FGmBg9oShG26vw4PDYT nvwf4QPsN7UVHIMPcsC2fTxFZFMmedNPyeWstFxCxEMItJmU/x1adPlc5hfRQh8DZF39 u03XsDSPTZ3YcxplX+QwagGjV6fUBEQMyJuKULcBZFQI9fKWZYYEpT2FD41lIYXiXYaZ q5KA== X-Gm-Message-State: AOJu0Yz9MY83bgHxruQ0znn0YtgWsHhWXpSacKwM03h4mN0Yj2CsIET8 av6nME/dh47FveX+ZOlLwV9vc04NqBpUaRphcpM+EBsRSvGZgrwMzGC+bZjL94sLSWXM14F6R4q ibHlM1DXlXThfloILKzrlnx2yiA1sOHVBZxCjLQ== X-Google-Smtp-Source: AGHT+IHIAnnGZKW+Y8xusuKDaboLn435mzof9VIF/eXHRIYoKjN2rrLeaaI2W91O1Oi662ftRSn5wfnPYogFbDdSuIw= X-Received: by 2002:a17:906:a419:b0:a47:3407:9286 with SMTP id l25-20020a170906a41900b00a4734079286mr684582ejz.22.1711102647280; Fri, 22 Mar 2024 03:17:27 -0700 (PDT) MIME-Version: 1.0 References: <20240321231149.519549-1-thiago.bauermann@linaro.org> In-Reply-To: <20240321231149.519549-1-thiago.bauermann@linaro.org> From: Christophe Lyon Date: Fri, 22 Mar 2024 11:17:17 +0100 Message-ID: Subject: Re: [RFC PATCH 0/3] Fix attaching to process when it has zombie threads To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Hi! On Fri, 22 Mar 2024 at 00:12, Thiago Jung Bauermann wrote: > > Hello, > > This patch series fixes a GDB hang when attaching to a multi-threaded > inferior which happens often (but not always) on aarch64-linux and > powerpc64le-linux, as described in PR 31312. See patch 3 for a detailed > descripiton of the problem. > > Patches 1 and 2 are preparatory patches because I want to use existing code > to parse the /proc/PID/stat file to get the thread's starttime value, so > that GDB and gdbserver aren't fooled by PID reuse. > > This patch series was tested on native and extended-remote aarch64-linux > and armv8l-linux-gnueabihf and no regressions were found, except for the > following: > > When running gdb.threads/detach-step-over.exp on armv8l-linux-gnueabihf > extended-remote, sometimes GDBserver dies with: > > builtin_spawn /home/thiago.bauermann/.cache/builds/gdb-native-aarch32/gdb/testsuite/outputs/gdb.threads/detach-step-over/detach-step-over > Remote debugging from host 127.0.0.1, port 56624 > Process /home/thiago.bauermann/.cache/builds/gdb-native-aarch32/gdb/testsuite/outputs/gdb.threads/detach-step-over/detach-step-over created; pid = 840876 > Attached; pid = 840821 > Detaching from process 840821 > Attached; pid = 840821 > /home/thiago.bauermann/src/binutils-gdb/gdbserver/linux-low.cc:1956: A problem internal to GDBserver has been detected. > unsuspend LWP 840821, suspended=-1 > > The assertion triggered is this one: > > /* Decrement LWP's suspend count. */ > > static void > lwp_suspended_decr (struct lwp_info *lwp) > { > lwp->suspended--; > > if (lwp->suspended < 0) > { > struct thread_info *thread = get_lwp_thread (lwp); > > internal_error ("unsuspend LWP %ld, suspended=%d\n", lwpid_of (thread), > lwp->suspended); > } > } > > Unfortunately for the moment I don't have time to further debug this > problem and I didn't want to keep sitting on these patches until I can come > back to this issue. > > Note that of all the testcases in the GDB testsuite, only > detach-step-over.exp triggers the GDBserver internal error so it's a > localized problem. > > This is why I'm posting the patch series as an RFC. Considering that it > fixes a problem that is causing instability in the testsuite results for > aarch64-linux and powerpc64le-linux, does it make sense to commit it as is, > and then investigate the GDBserver internal error on armv8l-linux-gnueabihf > later? I quickly looked at the series, patches 1 and 2 LGTM, I would say patch 3 too, but it seems to be causing the random failures you mention :-( However, I think your rationale is OK, trading many failures for a single, localized one. But of course, I'm not a maintainer :-) Thanks, Christophe > > Thiago Jung Bauermann (3): > gdb/nat: Use procfs(5) indexes in linux_common_core_of_thread > gdb/nat: Factor linux_find_proc_stat_field out of > linux_common_core_of_thread > gdb/nat/linux: Fix attaching to process when it has zombie threads > > gdb/nat/linux-osdata.c | 65 +++++++++++++++++++++++++++++++++--------- > gdb/nat/linux-osdata.h | 7 +++++ > gdb/nat/linux-procfs.c | 19 ++++++++++++ > 3 files changed, 77 insertions(+), 14 deletions(-) > > > base-commit: b42aa684f6ff2bce9b8bc58aa89574723f17f1ce