From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 23C4C38708D3 for ; Tue, 2 Jun 2020 14:53:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 23C4C38708D3 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-rDrHpIHgNk23ivhLGxh42w-1; Tue, 02 Jun 2020 10:53:45 -0400 X-MC-Unique: rDrHpIHgNk23ivhLGxh42w-1 Received: by mail-wr1-f71.google.com with SMTP id e7so1494421wrp.14 for ; Tue, 02 Jun 2020 07:53:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=30uYsKOL9v0l2e6YzaXFkZ2hjjU8l12R8+muYi29iZs=; b=tC/kXPPPcpjEEWv7o7zVdNTelIz2Pyq4pyGT2AWwKdoL/c6jY9pDsFI59mro6WTdn+ lOAZx4Y2CBDToCUUlXk223ybFApyvmoy0k1Js/nI8JDR4TPKjrXoq8QHn4FGMkn8fE/8 Z1hk3B08TpDbG3m8pC4qR49L+QGzbetC1XwkRiBysjsTsRVusakeja3ZjV0nWLZlzYTl jB1AJMUCv2sUqB0A3q2S8ep6YamMvjg0NuDTZUcDjsypSHryn4K7sKOc8dWFGKGpZ+on BanZpDkiU7/SIwYFYMe3Ed8cizefVF/6n6H1D90aPwnLodIZ/0u1gdDKks2Gy+l6r96U MDAw== X-Gm-Message-State: AOAM533FIr8pcpbIFqBNGZj2v+BYfkBIAw4SHWtvCyTRJkuRsRdU5nRN 7DRFY/vWuDpaKSWK3hN/7yjMti0PefOjZrfH70XXb9IbT47zBpUSUcgIN8+nTFSk5lwQNjOKIqB qjU38jWpF9xw= X-Received: by 2002:a1c:bd86:: with SMTP id n128mr4766901wmf.5.1591109620964; Tue, 02 Jun 2020 07:53:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/PkD8rXDO6i/ZTVDvEVnALyNuht0BqPIGSZU7rqlSS4HTxFNmZSGslSN6+GdgCdMs3Dzuyg== X-Received: by 2002:a1c:bd86:: with SMTP id n128mr4766888wmf.5.1591109620727; Tue, 02 Jun 2020 07:53:40 -0700 (PDT) Received: from ?IPv6:2001:8a0:f922:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f922:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id u7sm4120499wrm.23.2020.06.02.07.53.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Jun 2020 07:53:40 -0700 (PDT) Subject: Re: Solaris - procfs: couldn't find pid 32748 (kernel thread 21) in procinfo list To: Petr Sumbera , gdb@sourceware.org References: <5ab0b8b1-6072-6717-1ae0-ba06339254b8@oracle.com> <0570473c-1181-2269-06a0-0f6d4fc6b178@redhat.com> <51ff2398-4a7d-eb07-be98-0ae92673e152@oracle.com> From: Pedro Alves Message-ID: <6f4b62a6-3bcc-346e-ac69-a89e98f6dfbe@redhat.com> Date: Tue, 2 Jun 2020 15:53:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <51ff2398-4a7d-eb07-be98-0ae92673e152@oracle.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2020 14:53:50 -0000 On 6/2/20 8:32 AM, Petr Sumbera via Gdb wrote: > On 01.06.2020 21:12, Pedro Alves wrote: >> On 6/1/20 12:39 PM, Petr Sumbera via Gdb wrote: >>> The issue seems to be that the LWP exits and the status->kind is set to TARGET_WAITKIND_SPURIOUS: >>> >>> https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/procfs.c;h=f6c6b0e71c16224d3e7345ca09e011cdcf06349a;hb=HEAD#l2214 >>> >>> But instantly it's added into the list again here: >>> >>> https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/infrun.c;h=95fc3bfe45930b53c33cb4de165db9c070449ad8;hb=HEAD#l5200 >>> >>> But there is no longer such LWP in /proc. >>> >>> Any suggestion? > > Thanks for looking at it! > >> Either: >> >> - replace TARGET_WAITKIND_SPURIOUS with TARGET_WAITKIND_THREAD_EXITED, or, > > With this I'm getting: > > [LWP    21         exited] > [LWP    21         exited] > /builds/psumbera/userland-gdb-procinfo/components/gdb/gdb-9.2/gdb/thread.c:459: internal-error: void delete_thread_1(thread_info*, bool): Assertion `thr != nullptr' failed. > A problem internal to GDB has been detected, > further debugging may prove unreliable. > >> - replace >>      status->kind = TARGET_WAITKIND_SPURIOUS; >>      return retval; >>    with >>      goto wait_again; >>    instead. > > and with this: > > [LWP    20         exited] > [LWP    20         exited] > /builds/psumbera/userland-gdb-procinfo/components/gdb/gdb-9.2/gdb/thread.c:459: internal-error: void delete_thread_1(thread_info*, bool): Assertion `thr != nullptr' failed. > A problem internal to GDB has been detected, > further debugging may prove unreliable. > > -- > > Note that in both cases there are TWO exits for one LWP. But LWP numbers differ. You mean, it was 21 in one run, and 20 in another run? Those were two different runs, and some timing difference probably tweaked the order of which thread exits first or something. Doesn't seem unusual. Sounds like the patch below would fix it. But why do we get two exits in a row for each LWP? Oh, I guess once for PR_SYSENTRY of the exit syscall, and another time for PR_SYSEXIT. >From 0be6c82e754dd676e9f1259ab0f9a7849d985ffd Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 2 Jun 2020 15:44:54 +0100 Subject: [PATCH] fix-solaris --- gdb/procfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gdb/procfs.c b/gdb/procfs.c index f6c6b0e71c1..e2042f3edc4 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2331,9 +2331,10 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status, if (print_thread_events) printf_unfiltered (_("[%s exited]\n"), target_pid_to_str (retval).c_str ()); - delete_thread (find_thread_ptid (this, retval)); - status->kind = TARGET_WAITKIND_SPURIOUS; - return retval; + thread_info *thr = find_thread_ptid (this, retval); + if (thr != nullptr) + delete_thread (thr); + goto wait_again; } else if (0) { base-commit: f6eee2d098049afd18f90b8f4bb6a5d1a49d900c -- 2.14.5