Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Fix crash on CLI indented comments  [Re: [Bug:cli] Loading  user-defined function generates an internal  error]
       [not found]   ` <19259.54163.166299.854635@totara.tehura.co.nz>
@ 2010-01-01  8:41     ` Jan Kratochvil
  2010-01-01 10:36       ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2010-01-01  8:41 UTC (permalink / raw)
  To: Nick Roberts; +Cc: Joel Brobecker, gdb, gdb-patches

On Wed, 30 Dec 2009 23:26:27 +0100, Nick Roberts wrote:
> Heres a simpler user defined function that gives a segmentation fault.  It
> appears that GDB can no longer handle indented comments.
> 
> define my_fun
>  #indented comment
> end

      (*command)->line = savestring (p, p1 - p);
#1  0x0000000000487405 in savestring (ptr=0x1d5dd31 "", size=18446744073709551615) at utils.c:1377
(gdb) p/x size
$1 = 0xffffffffffffffff
(gdb) p p
$2 = 0x1d5dd31 ""
(gdb) p p1
$3 = 0x1d5dd30 " "


OK to check-in? Probably [obv].


Thanks,
Jan


2010-01-01  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cli/cli-script.c (process_next_line): Check P2 overrun.

--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -893,7 +893,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands)
 
   p2 = p;
   /* Strip leading whitespace.  */
-  while (*p2 == ' ' || *p2 == '\t')
+  while (p2 != p1 && (*p2 == ' ' || *p2 == '\t'))
     p2++;
 
   /* 'end' is always recognized, regardless of parse_commands value. 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Fix crash on CLI indented comments  [Re: [Bug:cli]  Loading user-defined function generates an internal  error]
  2010-01-01  8:41     ` [patch] Fix crash on CLI indented comments [Re: [Bug:cli] Loading user-defined function generates an internal error] Jan Kratochvil
@ 2010-01-01 10:36       ` Joel Brobecker
  2010-01-01 11:01         ` Jan Kratochvil
  2010-01-01 11:12         ` Joel Brobecker
  0 siblings, 2 replies; 4+ messages in thread
From: Joel Brobecker @ 2010-01-01 10:36 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Nick Roberts, gdb, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 642 bytes --]

> 2010-01-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* cli/cli-script.c (process_next_line): Check P2 overrun.

Yes - I agree it's obvious when you know that the comment is stripped
upstream...

Approved. Thanks for fixing.

Given the number of regressions/failures we've seen in this area,
I really thought we should add a test for this, so I created
the attached patch.  I will commit after you have committed yours.

gdb/testsuite/

        Test indented comment in file being sourced.
        * commands.exp: Test indented comment in file being sourced.

Tested on x86_64-linux.  Fails miserably without Jan's patch.

-- 
Joel

[-- Attachment #2: test-indented-comment.diff --]
[-- Type: text/x-diff, Size: 1246 bytes --]

commit 0f79c42a551762d87088fd5916c4ed390dde9942
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Fri Jan 1 14:31:07 2010 +0400

    Test indented comment in file being sourced.
    
            * commands.exp: Test indented comment in file being sourced.

diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 2aba51f..228c464 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -577,6 +577,19 @@ proc stray_arg0_test { } {
 	"stray_arg0_test #4"
 }
 
+# Test that GDB is able to source a file with an indented comment.
+proc source_file_with_indented_comment {} {
+    set fd [open "file1" w]
+    puts $fd \
+{define my_fun
+    #indented comment
+end
+echo Done!\n}
+    close $fd
+
+    gdb_test "source file1" "Done!" "source file with indented comment"
+}
+
 # Test that GDB can handle arguments when sourcing files recursively.
 # If the arguments are overwritten with ####### then the test has failed.
 proc recursive_source_test {} {
@@ -761,6 +774,7 @@ deprecated_command_test
 bp_deleted_in_command_test
 temporary_breakpoint_commands
 stray_arg0_test
+source_file_with_indented_comment
 recursive_source_test
 if_commands_test
 redefine_hook_test

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Fix crash on CLI indented comments  [Re: [Bug:cli]   Loading user-defined function generates an internal  error]
  2010-01-01 10:36       ` Joel Brobecker
@ 2010-01-01 11:01         ` Jan Kratochvil
  2010-01-01 11:12         ` Joel Brobecker
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2010-01-01 11:01 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Nick Roberts, gdb, gdb-patches

On Fri, 01 Jan 2010 11:35:20 +0100, Joel Brobecker wrote:
> Approved. Thanks for fixing.

Checked-in.


>         Test indented comment in file being sourced.
>         * commands.exp: Test indented comment in file being sourced.

OK, thanks for this work.


Regards,
Jan


http://sourceware.org/ml/gdb-cvs/2010-01/msg00014.html

--- src/gdb/ChangeLog	2010/01/01 09:44:05	1.11190
+++ src/gdb/ChangeLog	2010/01/01 10:57:42	1.11191
@@ -1,3 +1,7 @@
+2010-01-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* cli/cli-script.c (process_next_line): Check P2 overrun.
+
 2009-01-01  Joel Brobecker  <brobecker@adacore.com>
 
 	Update the copyright hearder to add year 2010 for most GDB files.
--- src/gdb/cli/cli-script.c	2010/01/01 07:31:47	1.55
+++ src/gdb/cli/cli-script.c	2010/01/01 10:57:43	1.56
@@ -893,7 +893,7 @@
 
   p2 = p;
   /* Strip leading whitespace.  */
-  while (*p2 == ' ' || *p2 == '\t')
+  while (p2 != p1 && (*p2 == ' ' || *p2 == '\t'))
     p2++;
 
   /* 'end' is always recognized, regardless of parse_commands value. 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Fix crash on CLI indented comments  [Re: [Bug:cli]   Loading user-defined function generates an internal  error]
  2010-01-01 10:36       ` Joel Brobecker
  2010-01-01 11:01         ` Jan Kratochvil
@ 2010-01-01 11:12         ` Joel Brobecker
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2010-01-01 11:12 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Nick Roberts, gdb, gdb-patches

> gdb/testsuite/
> 
>         Test indented comment in file being sourced.
>         * gdb.base/commands.exp: Test indented comment in file being sourced.

This patch is now in as well. (notice that I added the missing gdb.base
in the name of the file - oops)

-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-01 11:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <19258.59036.731093.439412@totara.tehura.co.nz>
     [not found] ` <20091230054617.GA548@adacore.com>
     [not found]   ` <19259.54163.166299.854635@totara.tehura.co.nz>
2010-01-01  8:41     ` [patch] Fix crash on CLI indented comments [Re: [Bug:cli] Loading user-defined function generates an internal error] Jan Kratochvil
2010-01-01 10:36       ` Joel Brobecker
2010-01-01 11:01         ` Jan Kratochvil
2010-01-01 11:12         ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox