From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24698 invoked by alias); 14 Mar 2013 12:53:32 -0000 Received: (qmail 24690 invoked by uid 22791); 14 Mar 2013 12:53:31 -0000 X-SWARE-Spam-Status: No, hits=-8.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_CP X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Mar 2013 12:53:22 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2ECrJhk027857 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 14 Mar 2013 08:53:19 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2ECrH2Y022408; Thu, 14 Mar 2013 08:53:17 -0400 Message-ID: <5141C83C.8090604@redhat.com> Date: Thu, 14 Mar 2013 12:53:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3 MIME-Version: 1.0 To: Jan Kratochvil CC: Hui Zhu , gdb-patches ml , Joel Brobecker Subject: Re: [patch+7.6] [TUI] Fix scrolling missing '>' 7.6 regression [Re: [PATCH] Fix gdb crash with tui] References: <513F7592.2080902@redhat.com> <20130313185507.GB18563@host2.jankratochvil.net> In-Reply-To: <20130313185507.GB18563@host2.jankratochvil.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-03/txt/msg00625.txt.bz2 On 03/13/2013 06:55 PM, Jan Kratochvil wrote: > On Tue, 12 Mar 2013 19:36:02 +0100, Pedro Alves wrote: >> Just doing any of these does fix the issue with the highlighted >> current line disappearing, so there's something else that needs >> fixing in addition. > > That is the second patch for a regression by me. Thanks. > #0 __memset_sse2 () at ../sysdeps/x86_64/memset.S:360 > #1 in freehook (ptr=0x3a61ba0, caller=0x879de9 ) at mcheck.c:193 > #2 in xfree (ptr=0x3a61ba0) at ./common/common-utils.c:108 > #3 in find_and_open_source (filename=0x23c2010 "gdb.c", dirname=0x289cec0 "/home/jkratoch/redhat/gdb-clean/gdb", fullname=0x289cde0) at source.c:1008 > #4 in open_source_file (s=0x289cd80) at source.c:1088 > #5 in tui_set_source_content (s=0x289cd80, line_no=16, noerror=0) at ./tui/tui-source.c:61 > #6 in tui_update_source_window_as_is (win_info=0x3a51a80, gdbarch=0x22d0000, s=0x289cd80, line_or_addr=..., noerror=0) at ./tui/tui-winsource.c:99 > #7 in tui_show_symtab_source (gdbarch=0x22d0000, s=0x289cd80, line=..., noerror=0) at ./tui/tui-source.c:339 > #8 in tui_update_source_windows_with_line (s=0x289cd80, line=16) at ./tui/tui-winsource.c:201 > #9 in tui_show_source (fullname=0x3a61ba0 "\225\225\225\225\225\225\225\225ratoch/redhat/gdb-clean/gdb/gdb.c", line=16) at ./tui/tui.c:542 > #10 in tui_field_string (uiout=0x2296dc0, fldno=3, width=0, align=ui_noalign, fldname=0xfa09d9 "fullname", string=0x3a61ba0 "\225\225\225\225\225\225\225\225ratoch/redhat/gdb-clean/gdb/gdb.c") at ./tui/tui-out.c:92 > #11 in uo_field_string (uiout=0x2296dc0, fldno=3, width=0, align=ui_noalign, fldname=0xfa09d9 "fullname", string=0x3a61ba0 "\225\225\225\225\225\225\225\225ratoch/redhat/gdb-clean/gdb/gdb.c") at ui-out.c:854 > #12 in ui_out_field_string (uiout=0x2296dc0, fldname=0xfa09d9 "fullname", string=0x3a61ba0 "\225\225\225\225\225\225\225\225ratoch/redhat/gdb-clean/gdb/gdb.c") at ui-out.c:544 > #13 in print_source_lines_base (s=0x289cd80, line=16, stopline=17, flags=PRINT_SOURCE_LINES_NOERROR) at source.c:1357 > #14 in print_source_lines (s=0x289cd80, line=16, stopline=17, flags=(unknown: 0)) at source.c:1442 > #15 in tui_vertical_source_scroll (scroll_direction=BACKWARD_SCROLL, num_to_scroll=1) at ./tui/tui-source.c:393 > #16 in tui_scroll_backward (win_to_scroll=0x3a51a80, num_to_scroll=1) at ./tui/tui-win.c:538 > #17 in tui_dispatch_ctrl_char (ch=259) at ./tui/tui-command.c:118 > #18 in tui_getc (fp=0x7ffff663b660 <_IO_2_1_stdin_>) at ./tui/tui-io.c:692 > #19 in rl_read_key () at input.c:448 > > > I did not expect this may happen... Took me a bit to realize why this was a problem, and why the copy fixed it. For the archives, the issue is here: void tui_show_source (const char *fullname, int line) { struct symtab_and_line cursal = get_current_source_symtab_and_line (); /* Make sure that the source window is displayed. */ tui_add_win_to_layout (SRC_WIN); tui_update_source_windows_with_line (cursal.symtab, line); tui_update_locator_fullname (fullname); } Where tui_update_locator_fullname is using a dangling pointer -- FULLNAME ends up released by tui_update_source_windows_with_line, as seen in the backtrace above. > 2013-03-13 Jan Kratochvil > > * source.c (print_source_lines_base): Make a local copy of > symtab_to_fullname. This is fine with me. > @@ -1355,11 +1355,17 @@ print_source_lines_base (struct symtab *s, int line, int stopline, > symtab_to_filename_for_display (s)); > if (ui_out_is_mi_like_p (uiout) > || !ui_out_test_flags (uiout, ui_source_list)) > - { > - const char *fullname = symtab_to_fullname (s); > + { > + const char *s_fullname = symtab_to_fullname (s); > + char *local_fullname; > > - ui_out_field_string (uiout, "fullname", fullname); > - } > + /* ui_out_field_string may free S_FULLNAME by calling > + open_source_file for it again. */ I wouldn't mind a mention of the TUI here to make future readers a bit less surprised: /* ui_out_field_string may free S_FULLNAME by calling open_source_file for it again. See e.g., tui_field_string->tui_show_source. */ > + local_fullname = alloca (strlen (s_fullname) + 1); > + strcpy (local_fullname, s_fullname); > + > + ui_out_field_string (uiout, "fullname", local_fullname); > + } > > ui_out_text (uiout, "\n"); > } -- Pedro Alves