* [PATCH] Fix some valgrind errors in the TUI
@ 2019-02-12 19:46 Tom Tromey
2019-02-17 15:35 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2019-02-12 19:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
The styling series introduced some new errors in the TUI -- the series
changed how source lines are allocated, without updating
tui_set_source_content_nil.
There are several failures but a typical one looks like:
==6274== Use of uninitialised value of size 8
==6274== at 0x4E4A095: wclrtoeol (in /usr/lib64/libncursesw.so.6.1)
==6274== by 0x4E47617: waddch (in /usr/lib64/libncursesw.so.6.1)
==6274== by 0x8325CB: tui_puts_internal(_win_st*, char const*, int*) (tui-io.c:393)
==6274== by 0x82E89D: tui_file::puts(char const*) (tui-file.c:39)
==6274== by 0x84BF5F: vfprintf_unfiltered(ui_file*, char const*, __va_list_tag*) (utils.c:2026)
This patch rewrites tui_set_source_content_nil, fixing the bug.
This was also reported as PR tui/24197.
Verified by running valgrind before and after on x86-64 Fedora 29.
gdb/ChangeLog
2019-02-12 Tom Tromey <tom@tromey.com>
PR tui/24197:
* tui/tui-source.c (tui_set_source_content_nil): Rewrite.
---
gdb/ChangeLog | 5 +++++
gdb/tui/tui-source.c | 21 +++++----------------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index a7e801eba26..7cc3c00069c 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -253,33 +253,22 @@ tui_set_source_content_nil (struct tui_win_info *win_info,
if (curr_line == (n_lines / 2 + 1))
{
- int i;
int xpos;
int warning_length = strlen (warning_string);
char *src_line;
- src_line = element->which_element.source.line;
-
if (warning_length >= ((line_width - 1) / 2))
xpos = 1;
else
xpos = (line_width - 1) / 2 - warning_length;
- for (i = 0; i < xpos; i++)
- src_line[i] = ' ';
-
- sprintf (src_line + i, "%s", warning_string);
-
- for (i = xpos + warning_length; i < line_width; i++)
- src_line[i] = ' ';
-
- src_line[i] = '\n';
-
- } /* end if */
+ src_line = xstrprintf ("%s%s", n_spaces (xpos), warning_string);
+ xfree (element->which_element.source.line);
+ element->which_element.source.line = src_line;
+ }
curr_line++;
-
- } /* end while */
+ }
}
--
2.17.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix some valgrind errors in the TUI
2019-02-12 19:46 [PATCH] Fix some valgrind errors in the TUI Tom Tromey
@ 2019-02-17 15:35 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2019-02-17 15:35 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> The styling series introduced some new errors in the TUI -- the series
Tom> changed how source lines are allocated, without updating
Tom> tui_set_source_content_nil.
Tom> There are several failures but a typical one looks like:
Tom> ==6274== Use of uninitialised value of size 8
Tom> ==6274== at 0x4E4A095: wclrtoeol (in /usr/lib64/libncursesw.so.6.1)
Tom> ==6274== by 0x4E47617: waddch (in /usr/lib64/libncursesw.so.6.1)
Tom> ==6274== by 0x8325CB: tui_puts_internal(_win_st*, char const*, int*) (tui-io.c:393)
Tom> ==6274== by 0x82E89D: tui_file::puts(char const*) (tui-file.c:39)
Tom> ==6274== by 0x84BF5F: vfprintf_unfiltered(ui_file*, char const*, __va_list_tag*) (utils.c:2026)
Tom> This patch rewrites tui_set_source_content_nil, fixing the bug.
I'm going to check this in, to unblock the release.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-17 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 19:46 [PATCH] Fix some valgrind errors in the TUI Tom Tromey
2019-02-17 15:35 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).