diff mbox

testsuite: Avoid a buffer overrun in `gdb.base/maint.exp'

Message ID alpine.DEB.2.00.1610191938330.31859@tp.orcam.me.uk
State Superseded
Headers show

Commit Message

Maciej W. Rozycki Oct. 19, 2016, 7:07 p.m. UTC
Similarly to commit ff604a674771 ("gdb/testsuite: Bump up `match_max'") 
fix a buffer overrun in `gdb.base/maint.exp':

PASS: gdb.base/maint.exp: maint w/o args
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/maint.exp: maint info line-table w/o a file name

observed in `mips-mti-linux-gnu' n64 ABI testing.  According to `string 
length $expect_out(buffer)' the count of characters actually retrieved 
in that testing is in the range of 133000, over twice as many as set for 
the limit with the latter change, and dependent on the amount of debug 
information retrieved from the system C library.  Therefore rather than 
bumping the global limit up again just change it temporarily with a 
suitable margin for the purpose of this single test case only.

	gdb/testsuite/
	* gdb.base/maint.exp: Override the `match_max' setting for the
	duration of the "maint info line-table w/o a file name" test.
---
Hi,

 I've looked into adjusting the size of the buffer dynamically as the 
`full_buffer' condition triggers and in principle it appears doable with 
the tools TCL and `expect' provide and no need to bend backwards to get it 
done, however it seems to require more than just a trivial intervention in 
`gdb_test_multiple', so I have decided to leave it for the next time the 
issue triggers.  Maybe it won't.

 Needless to say, this change has passed `mips-mti-linux-gnu' regression 
testing.  OK to apply?

  Maciej

gdb-test-maint-match-max.diff
diff mbox

Patch

Index: binutils/gdb/testsuite/gdb.base/maint.exp
===================================================================
--- binutils.orig/gdb/testsuite/gdb.base/maint.exp	2016-10-19 05:55:44.965881047 +0100
+++ binutils/gdb/testsuite/gdb.base/maint.exp	2016-10-19 06:40:39.310292228 +0100
@@ -474,9 +474,15 @@  gdb_test "maint" \
     "\"maintenance\" must be followed by the name of a maintenance command\\.\r\nList.*unambiguous\\..*" \
     "maint w/o args"
 
+# This can produce lots of output, so bump the buffer space a bit
+# temporarily, from our default set in `default_gdb_init'.
+set old_max [match_max -i $gdb_spawn_id]
+match_max -i $gdb_spawn_id 2097152
 gdb_test "maint info line-table" \
     "symtab: \[^\n\r\]+${srcfile}.*\\(\\(struct symtab \\*\\) $hex\\)\r\nlinetable: \\(\\(struct linetable \\*\\) $hex\\):\r\nINDEX.*LINE.*ADDRESS.*" \
     "maint info line-table w/o a file name"
+match_max -i $gdb_spawn_id $old_max
+unset old_max
 
 gdb_test "maint info line-table ${srcfile}" \
     "symtab: \[^\n\r\]+${srcfile}.*INDEX.*LINE.*ADDRESS.*" \