This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
Re: tui/1963: segfault when navigating in 'layout asm'
- From: Joshua Neuheisel <jneuheisel at gmail dot com>
- To: nobody at sources dot redhat dot com
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 23 Nov 2005 13:28:01 -0000
- Subject: Re: tui/1963: segfault when navigating in 'layout asm'
- Reply-to: Joshua Neuheisel <jneuheisel at gmail dot com>
The following reply was made to PR tui/1963; it has been noted by GNATS.
From: Joshua Neuheisel <jneuheisel@gmail.com>
To: gdb-gnats@sources.redhat.com
Cc:
Subject: Re: tui/1963: segfault when navigating in 'layout asm'
Date: Wed, 23 Nov 2005 08:23:59 -0500
Just some helpful information:
I can confirm this bug for gdb in CVS on 22 Nov 2005 with an i686
running Fedora Core 4 Linux/GNU, kernel version 2.6.13.
The problem occurs in tui_vertical_disassem_scroll, which is called when
the user presses the "down arrow" key as described in the bug report.
Since we've never seen a source code window yet, the function
set_current_source_symtab_and_line has not yet been called. This causes
the call to get_current_source_symtab_and_line to return a
symtab_and_line structure which is all zero. The logic of
tui_vertical_disassem_scroll then calls get_frame_pc on
deprecated_selected_frame, which is NULL. get_frame_pc tries to do a
NULL dereference, and SEG faults.
To fix the problem, I'm using the following patch. The main idea is
that tui_update_source_window_as_is ignores the symtab struct whenever
the first argument is not a SRC_WIN, so we can skip trying to find it in
the first place.
Index: gdb/tui/tui-disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-disasm.c,v
retrieving revision 1.15
diff -u -r1.15 tui-disasm.c
--- gdb/tui/tui-disasm.c 1 Nov 2005 17:40:25 -0000 1.15
+++ gdb/tui/tui-disasm.c 23 Nov 2005 13:12:57 -0000
@@ -379,16 +379,10 @@
{
CORE_ADDR pc;
tui_win_content content;
- struct symtab *s;
struct tui_line_or_address val;
int max_lines, dir;
- struct symtab_and_line cursal =
get_current_source_symtab_and_line ();
content = (tui_win_content) TUI_DISASM_WIN->generic.content;
- if (cursal.symtab == (struct symtab *) NULL)
- s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
- else
- s = cursal.symtab;
/* account for hilite */
max_lines = TUI_DISASM_WIN->generic.height - 2;
@@ -397,6 +391,6 @@
val.loa = LOA_ADDRESS;
val.u.addr = tui_find_disassembly_address (pc, dir);
- tui_update_source_window_as_is (TUI_DISASM_WIN, s, val, FALSE);
+ tui_update_source_window_as_is (TUI_DISASM_WIN, NULL, val, FALSE);
}
}
Joshua Neuheisel
jneuheisel@gmail.com