Bug 11293 - gdb is broken on Linux/i386
Summary: gdb is broken on Linux/i386
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: shlibs (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 7.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-17 19:53 UTC by H.J. Lu
Modified: 2010-02-17 20:50 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2010-02-17 19:53:39 UTC
When I ran "make check" on Linux/i386 with gdb trunk on
2010-02-17, I got

Starting program:
/export/build/gnu/gdb/build-i686-linux/gdb/testsuite/gdb.arch/i386-disp-step ^M
/net/gnu-6/export/gnu/import/git/gdb/gdb/solib-svr4.c:1468: internal-error:
enable_break: Assertion `load_addr < space_size' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) FAIL: gdb.arch/i386-disp-step.exp: running
to main in runto (timeout)
FAIL: gdb.arch/i386-disp-step.exp: Can't run to main

It may be caused by

http://sourceware.org/ml/gdb-cvs/2010-02/msg00083.html
Comment 1 H.J. Lu 2010-02-17 19:56:46 UTC
I meant this patch:

http://sourceware.org/ml/gdb-cvs/2010-02/msg00135.html
Comment 2 H.J. Lu 2010-02-17 20:02:21 UTC
This code

---
            if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
              {    
                CORE_ADDR space_size = (ULONGEST) 1 << addr_bit;
                CORE_ADDR tmp_entry_point = exec_entry_point (tmp_bfd,
                                                              tmp_bfd_target);

                gdb_assert (load_addr < space_size);

                /* TMP_ENTRY_POINT exceeding SPACE_SIZE would be for prelinked
                   64bit ld.so with 32bit executable, it should not happen.  */

                if (tmp_entry_point < space_size
                    && tmp_entry_point + load_addr >= space_size)
                  load_addr -= space_size;
              }    
---

doesn't make much senses. For 32bit, addr_bit is 32 and CORE_ADDR is
4 byte.

CORE_ADDR space_size = (ULONGEST) 1 << addr_bit;

will overflow.
Comment 3 H.J. Lu 2010-02-17 20:06:30 UTC
This patch:

---
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index b3b9e00..f4fccb2 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1459,7 +1459,7 @@ enable_break (struct svr4_info *info, int from_tty)
          invalid addresses like 0x101234567 for 32bit inferiors on 64bit
          GDB.  */
 
-      if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
+      if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
         {
      CORE_ADDR space_size = (ULONGEST) 1 << addr_bit;
      CORE_ADDR tmp_entry_point = exec_entry_point (tmp_bfd,
--

seems to work.
Comment 4 H.J. Lu 2010-02-17 20:17:22 UTC
A patch is posted at

http://sourceware.org/ml/gdb-patches/2010-02/msg00439.html
Comment 5 Sourceware Commits 2010-02-17 20:47:20 UTC
Subject: Bug 11293

CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2010-02-17 20:47:08

Modified files:
	gdb            : ChangeLog solib-svr4.c 

Log message:
	Use CORE_ADDR instead of ULONGEST on address.
	
	2010-02-17  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR shlibs/11293
	* solib-svr4.c (enable_break): Check size of CORE_ADDR instead
	of ULONGEST for address size.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11372&r2=1.11373
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/solib-svr4.c.diff?cvsroot=src&r1=1.123&r2=1.124

Comment 6 H.J. Lu 2010-02-17 20:50:22 UTC
Fixed.