From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id EABD43850432 for ; Tue, 13 Jul 2021 13:15:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EABD43850432 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 127EF2283B; Tue, 13 Jul 2021 13:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626182115; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ks1Mxda2Qi2ItBU+BjEIaIY2DCWlIbatGAVqmw/LT+Q=; b=sFLnX71lCeLmSdeNlm8eTcvDjX4Ll4rHUJTu+nMG/ab0JnplspkCbdoECGnRB+itNAvM+T 2e2N8AMwT/4PePdvG5u+UoDGqgOw2xqhCQhUhOm2grIHusLFfv4k3aH4KbS2PYRqHkGEbO g7Vh11KH8gHS5bko77mQkxPM8AHHv5M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626182115; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ks1Mxda2Qi2ItBU+BjEIaIY2DCWlIbatGAVqmw/LT+Q=; b=pAhMDW/PQwPLNge6vq2suBCPffwpn7+TLY6jfnYtUAMLccoIg75p/YAZ6O3h8QAOgWI5Ie /0g/Qm4EhNsObsAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E203513AE9; Tue, 13 Jul 2021 13:15:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mpiVNeKR7WArEAAAMHmgww (envelope-from ); Tue, 13 Jul 2021 13:15:14 +0000 Subject: Re: [PATCH][gdb/testsuite] Fix check-libthread-db.exp FAILs with glibc 2.33 From: Tom de Vries To: Simon Marchi , gdb-patches@sourceware.org References: <20210707140950.GA2241@delia> <2421785c-a5b9-64b7-371c-0abf35a4cb63@polymtl.ca> Message-ID: <2b07a32d-b3f7-cfc6-92a0-2eb7425df519@suse.de> Date: Tue, 13 Jul 2021 15:15:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------FA34643F89B4645A2A0D0EB9" Content-Language: en-US X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP 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: Tue, 13 Jul 2021 13:15:18 -0000 This is a multi-part message in MIME format. --------------FA34643F89B4645A2A0D0EB9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 7/13/21 2:59 PM, Tom de Vries wrote: > I'll try to update the log message a bit and resubmit. Any further comments? Thanks, - Tom --------------FA34643F89B4645A2A0D0EB9 Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-testsuite-Fix-check-libthread-db.exp-FAILs-with-glibc-2.33.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-gdb-testsuite-Fix-check-libthread-db.exp-FAILs-with-gli"; filename*1="bc-2.33.patch" [gdb/testsuite] Fix check-libthread-db.exp FAILs with glibc 2.33 When running test-case gdb.threads/check-libthread-db.exp on openSUSE Tumbleweed with glibc 2.33, I get: ... (gdb) maint check libthread-db^M Running libthread_db integrity checks:^M Got thread 0x7ffff7c79b80 => 9354 => 0x7ffff7c79b80; errno = 0 ... OK^M libthread_db integrity checks passed.^M (gdb) FAIL: gdb.threads/check-libthread-db.exp: user-initiated check: \ libpthread.so not initialized (pattern 2) ... The test-case expects instead: ... Got thread 0x0 => 9354 => 0x0 ... OK^M ... which is what I get on openSUSE Leap 15.2 with glibc 2.26, and what is described in the test-case like this: ... # libthread_db should fake a single thread with th_unique == NULL. ... Using a breakpoint on check_thread_db_callback we can compare the two scenarios, and find that in the latter case we hit this code in glibc function iterate_thread_list in nptl_db/td_ta_thr_iter.c: ... if (next == 0 && fake_empty) { /* __pthread_initialize_minimal has not run. There is just the main thread to return. We cannot rely on its thread register. They sometimes contain garbage that would confuse us, left by the kernel at exec. So if it looks like initialization is incomplete, we only fake a special descriptor for the initial thread. */ td_thrhandle_t th = { ta, 0 }; return callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK; } ... while in the former case we don't because this preceding statement doesn't result in next == 0: ... err = DB_GET_FIELD (next, ta, head, list_t, next, 0); ... Note that the comment mentions __pthread_initialize_minimal, but in both cases it has already run before we hit the callback, so it's possible the comment is no longer accurate. The change in behaviour bisect to glibc commit 1daccf403b "nptl: Move stack list variables into _rtld_global", which moves the initialization of stack list variables such as __stack_user to an earlier moment, which explains well enough the observed difference. Fix this by updating the regexp patterns to agree with what libthread-db is telling us. Tested on x86_64-linux, both with glibc 2.33 and 2.26. gdb/testsuite/ChangeLog: 2021-07-07 Tom de Vries PR testsuite/27690 * gdb.threads/check-libthread-db.exp: Update patterns for glibc 2.33. --- gdb/testsuite/gdb.threads/check-libthread-db.exp | 37 ++++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/gdb/testsuite/gdb.threads/check-libthread-db.exp b/gdb/testsuite/gdb.threads/check-libthread-db.exp index dfb3bad3712..6ecf40db6a9 100644 --- a/gdb/testsuite/gdb.threads/check-libthread-db.exp +++ b/gdb/testsuite/gdb.threads/check-libthread-db.exp @@ -32,6 +32,13 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } +# Case 1: libthread_db fakes a single thread with th_unique == NULL. +set thread_re1 "0 => $decimal => 0" +# Case 2: libthread_db already initialized. +set thread_re2 "$hex => $decimal => ${hex}(; errno = 0)?" +# Match either of the two cases. +set initial_thread_re "($thread_re1|$thread_re2)" + with_test_prefix "user-initiated check" { # User-initiated check with libthread_db not loaded. @@ -49,18 +56,16 @@ with_test_prefix "user-initiated check" { "No libthread_db loaded" \ "no libpthread.so loaded" - - # User-initiated check with NPTL uninitialized. - # libthread_db should fake a single thread with th_unique == NULL. + # User-initiated check with NPTL possibly uninitialized. gdb_test "continue" \ ".*Stopped due to shared library event.*Inferior loaded .*libpthread.*" gdb_test_sequence "maint check libthread-db" \ - "libpthread.so not initialized" { - "\[\r\n\]+Running libthread_db integrity checks:" - "\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK" - "\[\r\n\]+libthread_db integrity checks passed." - } + "libpthread.so possibly not initialized" \ + [list \ + "\[\r\n\]+Running libthread_db integrity checks:" \ + "\[\r\n\]+\[ \]+Got thread $initial_thread_re ... OK" \ + "\[\r\n\]+libthread_db integrity checks passed."] # User-initiated check with NPTL fully operational. gdb_test_no_output "set stop-on-solib-events 0" @@ -78,8 +83,8 @@ with_test_prefix "user-initiated check" { with_test_prefix "automated load-time check" { - # Automated load-time check with NPTL uninitialized. - with_test_prefix "libpthread.so not initialized" { + # Automated load-time check with NPTL possibly uninitialized. + with_test_prefix "libpthread.so possibly not initialized" { clean_restart ${binfile} gdb_test_no_output "maint set check-libthread-db 1" @@ -88,12 +93,12 @@ with_test_prefix "automated load-time check" { gdb_run_cmd gdb_test_sequence "" \ - "check debug libthread-db output" { - "\[\r\n\]+Running libthread_db integrity checks:" - "\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK" - "\[\r\n\]+libthread_db integrity checks passed." - "\[\r\n\]+[Thread debugging using libthread_db enabled]" - } + "check debug libthread-db output" \ + [list \ + "\[\r\n\]+Running libthread_db integrity checks:" \ + "\[\r\n\]+\[ \]+Got thread $initial_thread_re ... OK" \ + "\[\r\n\]+libthread_db integrity checks passed." \ + "\[\r\n\]+\\\[Thread debugging using libthread_db enabled\\\]"] } # Automated load-time check with NPTL fully operational. --------------FA34643F89B4645A2A0D0EB9--