[Bug gdb/17756] New: gdb find command returns bogus results and can't find the matched value.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] New: gdb find command returns bogus results and can't find the matched value.

glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

            Bug ID: 17756
           Summary: gdb find command returns bogus results and can't find
                    the matched value.
           Product: gdb
           Version: 6.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: liuyefenglin at gmail dot com

Version info:
GNU gdb (Wind River Linux Sourcery G++ 4.3a-335) 6.8.50.20080821-cvs
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

(gdb) info target
    0x08048000 - 0x08048000 is load1
    0x080b2000 - 0x080b3000 is load2
    0x080b3000 - 0x09c9e000 is load3   //Should be heap region.
(gdb) show mem inaccessible-by-default
Unknown memory addresses will be treated as RAM.


//find command returns bogus results
(gdb) find/w 0x080b3000,0x09c9e000,0x8988b90
0x837f948
1 pattern found.
(gdb) x 0x837f948
0x837f948:    0xb6976c0a


//find command can't find the matched value
(gdb) find/w 0x0837ba00,0x0837bb00,0x8988b90
0x837bac8
1 pattern found.
(gdb) x 0x837bac8
0x837bac8:    0x08988b90
(gdb) find/w 0x08370000,0x0837bb00,0x8988b90
Pattern not found.

It seems that the find command doesn't works well when the search region is
large. This command is very important to debug core dump of memory corruptions.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

Rody Liu <liuyefenglin at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |liuyefenglin at gmail dot com

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

dje at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at google dot com

--- Comment #1 from dje at google dot com ---
6.8 is ancient.

It would be good to first verify the problem still exists in current gdb.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

Matthew Street <matt.street at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matt.street at gmail dot com

--- Comment #2 from Matthew Street <matt.street at gmail dot com> ---
I just confirmed this with 7.9 from Ubuntu Precise 32. I also have confirmed it
with 7.4 installed on my mac with homebrew.

Short example, I can give my data if need be:
(gdb) info proc mapping
-snip-
0xbffdf000 0xc0000000    0x21000        0x0 [stack]

find.gdb:
break test
run
find /b 0xbffdf000, 0xc0000000, 0x00

$> gdb -x find.gdb ./a.out > find.log
warning: Unable to access target memory at 0xbfffc181, halting search

But 0xbfffc181 is accessible:
(gdb) x /b 0xbfffc181
0xbfffc181: 0

And a smaller search range works fine:

(gdb) find /b 0xbfffc181, 0xbfffc191, 0x00
0xbfffc181
0xbfffc182
0xbfffc183
0xbfffc184
0xbfffc185
0xbfffc186
0xbfffc187
0xbfffc188
0xbfffc189
0xbfffc18a
0xbfffc18b
0xbfffc18c
0xbfffc18d
0xbfffc18e
0xbfffc18f
0xbfffc190
0xbfffc191
17 patterns found.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |palves at redhat dot com

--- Comment #3 from Pedro Alves <palves at redhat dot com> ---
Looks like an off-by-one -- GDB requests one byte-too-much?

(gdb) info proc mappings
process 8283
Mapped address spaces:

      0x7ffffffdd000     0x7ffffffff000    0x22000        0x0 [stack]
(gdb) find /b 0x7ffffffdd000, 0x7ffffffff000, 0xa5
warning: Unable to access 11265 bytes of target memory at 0x7fffffffc400,      
halting search.
Pattern not found.
(gdb) p /x 0x7fffffffc400 + 11265
$1 = 0x7ffffffff001
(gdb)

The problem is probably in gdb/target.c:simple_search_memory.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Bug 11158 also is about find returning incorrect results.
I wonder if there's an easy way to reproduce this.
At least at first glance, find.exp seems pretty complete.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Pedro Alves from comment #3)
> Looks like an off-by-one -- GDB requests one byte-too-much?

I think it's just findcmd.c:

      search_space_len = end_addr - start_addr + 1;

0x7ffffffff000 - 0x7ffffffdd000 + 1 == 0x22001

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Pedro Alves from comment #3)

Off by one makes my head hurt.

> Mapped address spaces:
>
>       0x7ffffffdd000     0x7ffffffff000    0x22000        0x0 [stack]

I think this range is exclusive on the high end?
That is 0x7ffffffff000 is not included.

> (gdb) find /b 0x7ffffffdd000, 0x7ffffffff000, 0xa5

However "find" is inclusive on the high end.
Probably a bad choice (IMO) but on the other hand,
maybe more confusing to change it at this point.

So, I don't think there's a bug here.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/17756] gdb find command returns bogus results and can't find the matched value.

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17756

--- Comment #7 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Rody Liu from comment #0)

> (gdb) info target
> 0x08048000 - 0x08048000 is load1
> 0x080b2000 - 0x080b3000 is load2
> 0x080b3000 - 0x09c9e000 is load3   //Should be heap region.
> (gdb) show mem inaccessible-by-default
> Unknown memory addresses will be treated as RAM.
>
>
> //find command returns bogus results
> (gdb) find/w 0x080b3000,0x09c9e000,0x8988b90
> 0x837f948

This one could well be something weird about the target, I guess.
Without more information though it is hard to know.

> //find command can't find the matched value
> (gdb) find/w 0x0837ba00,0x0837bb00,0x8988b90
> 0x837bac8
> 1 pattern found.
> (gdb) x 0x837bac8
> 0x837bac8: 0x08988b90
> (gdb) find/w 0x08370000,0x0837bb00,0x8988b90
> Pattern not found.

I duplicated this as a unit test and couldn't reproduce
the failure.

--
You are receiving this mail because:
You are on the CC list for the bug.