public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Avoid expect's buffer overflow in info-var.exp test.
@ 2019-09-04 20:41 Philippe Waroquiers
  0 siblings, 0 replies; only message in thread
From: Philippe Waroquiers @ 2019-09-04 20:41 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=98b0ebab0a1eb0c1f179ebe633250e7201d35bce

commit 98b0ebab0a1eb0c1f179ebe633250e7201d35bce
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Sat Aug 31 17:25:54 2019 +0200

    Avoid expect's buffer overflow in info-var.exp test.
    
    Once the executable is started, info variables can show thousands
    of variables belonging to glibc (see below).
    
    This long list of variables then causes the test to fail, due
    to expect's buffer overflow:
      Running /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/info-var.exp ...
      ERROR: internal buffer is full.
      ERROR: internal buffer is full.
      ERROR: internal buffer is full.
    
    Fix this by testing 'info variables' without running the executable.
    
    gdb ./info-var
    ...
    Reading symbols from ./info-var...
    (gdb) |info variables|wc
         27      54     971
    (gdb) start
    Temporary breakpoint 1 at 0x1129: file /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/info-var-f1.c, line 23.
    Starting program: /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/outputs/gdb.base/info-var/info-var
    
    Temporary breakpoint 1, main ()
        at /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.base/info-var-f1.c:23
    23	  return global_var + get_offset() + f1_var;
    (gdb) |info variables|wc
       4334   14581  130738
    (gdb)
    
    gdb/testsuite/ChangeLog
    2019-09-04  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
    
    	* gdb.base/info-var.exp: Test info variables without running
    	to main, to avoid expect's buffer overflow.

Diff:
---
 gdb/testsuite/ChangeLog             | 5 +++++
 gdb/testsuite/gdb.base/info-var.exp | 7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d2dc356..46c7b5f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-09-04  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+	* gdb.base/info-var.exp: Test info variables without running
+	to main, to avoid expect's buffer overflow.
+
 2019-09-03  Tom Tromey  <tromey@adacore.com>
 
 	* gdb.ada/bias.exp: New file.
diff --git a/gdb/testsuite/gdb.base/info-var.exp b/gdb/testsuite/gdb.base/info-var.exp
index 6dd896d..c9b7485 100644
--- a/gdb/testsuite/gdb.base/info-var.exp
+++ b/gdb/testsuite/gdb.base/info-var.exp
@@ -22,10 +22,9 @@ if {[prepare_for_testing "failed to prepare" \
     return -1
 }
 
-if ![runto_main] then {
-    fail "can't run to main"
-    return 0
-}
+# Note: we do not run to main, as otherwise, the output of info variables
+# can be very long, showing thousands of glibc variables.
+# This long output then causes expect's buffer to overflow.
 
 gdb_test "info variables" \
     [multi_line \


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-04 20:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 20:41 [binutils-gdb] Avoid expect's buffer overflow in info-var.exp test Philippe Waroquiers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).