This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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
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.*" \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]