diff options
author | Guinevere Larsen <guinevere@redhat.com> | 2025-09-01 11:48:30 -0300 |
---|---|---|
committer | Guinevere Larsen <guinevere@redhat.com> | 2025-09-04 14:56:37 -0300 |
commit | e90c268b3e142bd97b10425fd32ea0d3ea1c8d07 (patch) | |
tree | 5bb469ace839d60fef2e276986e82e18f3c72d04 | |
parent | 88d6ee4c9afcf4e08b691e0d82d247d51ed70e8a (diff) | |
download | binutils-e90c268b3e142bd97b10425fd32ea0d3ea1c8d07.zip binutils-e90c268b3e142bd97b10425fd32ea0d3ea1c8d07.tar.gz binutils-e90c268b3e142bd97b10425fd32ea0d3ea1c8d07.tar.bz2 |
gdb/testsuite: fix possible TCL errors in gdb.threads/threadcrash.exp
The test gdb.threads/threadcrash.exp, among other things, creates a list
of the threads seen in the order that the "thread apply all backtrace"
would generate them, tests that this list is the same size as GDB's
count of threads, and then loops over the list to check that each
thread has the expected backtrace.
A problem occurs because the loop iterates on GDB's internal count of
threads, rather than the size of the list, but then attempts to acces
the n-th element of the list. If the list size is smaller than GDB's
internal thread count, it'll access past the end of the list and
generate TCL errors.
This commit fixes this by using the list's length instead.
Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r-- | gdb/testsuite/gdb.threads/threadcrash.exp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp index 76d2c6c..8df8578 100644 --- a/gdb/testsuite/gdb.threads/threadcrash.exp +++ b/gdb/testsuite/gdb.threads/threadcrash.exp @@ -132,8 +132,9 @@ proc do_full_test {} { set pthread_kill ".*" } - for {set i 0} {$i < $thread_count } {incr i} { - set thread_num [expr [llength $test_list] - $i] + set loop_iterations [llength $test_list] + for {set i 0} {$i < $loop_iterations } {incr i} { + set thread_num [expr $loop_iterations - $i] set type [lindex $test_list $i] if { $type == 1 } { |