From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Vn/OCcPQ6mlf0jcAWB0awg (envelope-from ) for ; Thu, 23 Apr 2026 22:09:07 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CIExHHPg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0ED8B1E0BA; Thu, 23 Apr 2026 22:09:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 40FFC1E093 for ; Thu, 23 Apr 2026 22:09:06 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 387924BB1C1A for ; Fri, 24 Apr 2026 02:09:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 387924BB1C1A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CIExHHPg Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 6ACB74BB1C00 for ; Fri, 24 Apr 2026 02:08:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6ACB74BB1C00 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6ACB74BB1C00 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776996518; cv=none; b=gP6YSm0pbVSbVE5io1VLdqgW4FculXUt0MM51txweBX2Nj44nhlmLXRqcZgNKIer7thZ2iC10XVJEWxgi6tW+mNXwOChxfHDyqUg6eTUmo+Img4H/kpYRgrnNz8f5OothDPCqzGyKZxQrH45NtaeV7d0qvjt0o/ImbLEFWOqcBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776996518; c=relaxed/simple; bh=NZRL/wMrDvPVNuwEBt83SYQrelPQYuOgyggnZqgNPas=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Y6IObcTAJ/FVVdn1yoZ8yuWNzh6d25QNtH53n+H9Nu6sNmCktWTdq85F41iSm0l2y0u+Y5cYQP6ND6DeVYfSBn8UAuGr4CXC1pn9Hx2edA3wS00WOcEQd9tABq+Jo7McmgQPl0PzKNoCrml5zkvFVDua6bTScr+JVmvYQOYQxzI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6ACB74BB1C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776996518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j8p4NNmwRCUTt628JY7bN4JN2ecbJUPILO7nF3xSfHQ=; b=CIExHHPgdclTh1x+6/6G3WNGekrexdFET0PMCQjgXdZpGdhlRZKgeocJiMcsZPG0tjDPJw IfEr+pYOmyZfDTZWac+jpzwQh4uyjFXdXcX4Dm8p2duCDI6uDXQ0sBDWXBUTA21u6Bhex/ 3O/J8EAk/j/iAGxbt72FScupTZbMjXQ= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-PIgARdhCOj2ua9aRQee5yg-1; Thu, 23 Apr 2026 22:08:33 -0400 X-MC-Unique: PIgARdhCOj2ua9aRQee5yg-1 X-Mimecast-MFC-AGG-ID: PIgARdhCOj2ua9aRQee5yg_1776996513 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD9DD19560BB; Fri, 24 Apr 2026 02:08:32 +0000 (UTC) Received: from f42-zbm-amd (unknown [10.22.80.51]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0CCD5180047F; Fri, 24 Apr 2026 02:08:31 +0000 (UTC) Date: Thu, 23 Apr 2026 19:08:29 -0700 From: Kevin Buettner To: "Maciej W. Rozycki" Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] GDB/testsuite: Fix schedlock.exp crash due to empty $after_args Message-ID: <20260423190829.20992b53@f42-zbm-amd> In-Reply-To: References: Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aHX6xF6IVQ5WucFSR4p9dDGADaqQ3ONpuzCKSPRiaLs_1776996513 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Wed, 22 Apr 2026 23:21:05 +0100 (BST) "Maciej W. Rozycki" wrote: > From: "Maciej W. Rozycki" > To: gdb-patches@sourceware.org > Subject: [PATCH] GDB/testsuite: Fix schedlock.exp crash due to empty > $after_args Date: Wed, 22 Apr 2026 23:21:05 +0100 (BST) > User-Agent: Alpine 2.21 (DEB 202 2017-01-01) > > Prevent gdb.threads/schedlock.exp from crashing due to a premature exit > of the debuggee causing an attempt to use a nil value as an arithmetic > operand: > > [...] > (gdb) FAIL: gdb.threads/schedlock.exp: schedlock=off: cmd=next: > call_function=0: next to increment, 9 bt > The current thread has terminated > (gdb) FAIL: gdb.threads/schedlock.exp: schedlock=off: cmd=next: > call_function=0: find current thread, after FAIL: > gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=0: next > does not change thread (switched to thread ) print args Cannot access > memory at address 0x410ab0 (gdb) FAIL: gdb.threads/schedlock.exp: > schedlock=off: cmd=next: call_function=0: listed args, after ERROR: tcl > error sourcing .../gdb/testsuite/gdb.threads/schedlock.exp. ERROR: can't > use empty string as operand of "-" while executing > "if {$cmd == "continue" > || [lindex $before_args $i] == [lindex $after_args > $i] - 10} { pass "$test" > } else { > fail "$test (wrong amo..." > (procedure "check_result" line 31) > invoked from within > "check_result $cmd $curthread $before_args $locked" > (procedure "test_step" line 26) > invoked from within > "test_step $schedlock "next" $call_function" > ("uplevel" body line 2) > invoked from within > "uplevel 1 $body" > invoked from within > "with_test_prefix "call_function=$call_function" { > test_step $schedlock "next" $call_function > }" > ("foreach" body line 2) > invoked from within > "foreach call_function {0 1} { > with_test_prefix "call_function=$call_function" { > test_step $schedlock "next" $call_function > } > }" > ("uplevel" body line 6) > invoked from within > "uplevel 1 $body" > invoked from within > "with_test_prefix "cmd=next" { > # In GDB <= 7.9, with schedlock "step", "next" would > # unlock threads when stepping over a function call. Thi..." > ("uplevel" body line 5) > invoked from within > "uplevel 1 $body" > invoked from within > "with_test_prefix "schedlock=$schedlock" { > with_test_prefix "cmd=step" { > test_step $schedlock "step" 0 > } > with_test_prefix "cmd=next" { > # I..." > ("foreach" body line 2) > invoked from within > "foreach schedlock {"off" "step" "on"} { > with_test_prefix "schedlock=$schedlock" { > with_test_prefix "cmd=step" { > test_step $schedlock "step" ..." > (file ".../gdb/testsuite/gdb.threads/schedlock.exp" line 297) > invoked from within > "source .../gdb/testsuite/gdb.threads/schedlock.exp" > ("uplevel" body line 1) > invoked from within > "uplevel #0 source .../gdb/testsuite/gdb.threads/schedlock.exp" > invoked from within > "catch "uplevel #0 source $test_file_name"" > Remote debugging from host xx.xx.xx.xx, port 56596 > monitor exit > (gdb) Killing process(es): 22658 > testcase .../gdb/testsuite/gdb.threads/schedlock.exp completed in 32 > seconds > > Here `print args' has failed to produce output matching the pattern > expected by `get_args' and consequently an empty value has been assigned > to $after_args. Subsequently a calculation is attempted on an element > of said value treated as a list: `[lindex $after_args $i] - 10' and that > has caused the crash because the resulting minuend is nil. > > There are various expressions $after_args and other variables set from > the result of `get_args' are used in, however the majority are equality > operations, which succeed producing a result even where a nil operand is > involved. Given that this is a test failure scenario anyway follow the > path of least resistance, ignore the other expressions and just prevent > the crash from triggering here by checking for an attempt to retrieve an > inexistent element of $after_args for this calculation, and report it as > a test failure outright letting the script proceed: > > [...] > (gdb) FAIL: gdb.threads/schedlock.exp: schedlock=off: cmd=next: > call_function=0: next to increment, 9 bt > The current thread has terminated > (gdb) FAIL: gdb.threads/schedlock.exp: schedlock=off: cmd=next: > call_function=0: find current thread, after FAIL: > gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=0: next > does not change thread (switched to thread ) print args Cannot access > memory at address 0x410ab0 (gdb) FAIL: gdb.threads/schedlock.exp: > schedlock=off: cmd=next: call_function=0: listed args, after FAIL: > gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=0: > current thread advanced - unlocked (no arg #1) PASS: > gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=0: > other threads ran - unlocked set scheduler-locking off (gdb) PASS: > gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=1: set > scheduler-locking off [...] --- gdb/testsuite/gdb.threads/schedlock.exp | > 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) > > gdb-test-schedlock-no-args.diff > Index: binutils-gdb/gdb/testsuite/gdb.threads/schedlock.exp > =================================================================== > --- binutils-gdb.orig/gdb/testsuite/gdb.threads/schedlock.exp > +++ binutils-gdb/gdb/testsuite/gdb.threads/schedlock.exp > @@ -232,8 +232,12 @@ proc check_result { cmd before_thread be > } > } else { > if {$i == $before_thread} { > - if {$cmd == "continue" > - || [lindex $before_args $i] == [lindex $after_args > $i] - 10} { > + if {$cmd == "continue"} { > + pass "$test" > + } elseif {[llength $after_args] <= $i} { > + fail "$test (no arg #$i)" > + } elseif {[lindex $before_args $i] \ > + == [lindex $after_args $i] - 10} { > pass "$test" > } else { > fail "$test (wrong amount)" > LGTM. Thanks for this fix. Approved-by: Kevin Buettner