Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MTgAx-00031l-2z for mharc-grub-devel@gnu.org; Wed, 22 Jul 2009 14:04:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MTgAv-00030E-Qa for grub-devel@gnu.org; Wed, 22 Jul 2009 14:04:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MTgAr-0002tf-2t for grub-devel@gnu.org; Wed, 22 Jul 2009 14:04:21 -0400 Received: from [199.232.76.173] (port=49159 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTgAq-0002tT-Qz for grub-devel@gnu.org; Wed, 22 Jul 2009 14:04:16 -0400 Received: from aybabtu.com ([69.60.117.155]:44377) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MTgAq-0001Vt-7f for grub-devel@gnu.org; Wed, 22 Jul 2009 14:04:16 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1MTf50-0007C8-MT for grub-devel@gnu.org; Wed, 22 Jul 2009 18:54:11 +0200 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1MTgAk-0002PU-MA for grub-devel@gnu.org; Wed, 22 Jul 2009 20:04:10 +0200 Date: Wed, 22 Jul 2009 20:04:10 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20090722180410.GQ8706@thorin> References: <8FB98151-B0A2-4308-A065-15607AE9E8D8@gmail.com> <20090718185800.GJ8867@thorin> <0CC61931-97E9-4B53-8B86-37129AE84218@gmail.com> <20090722172709.GF8706@thorin> <1F7F9766-ABCD-4190-AA2D-C028D6348094@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1F7F9766-ABCD-4190-AA2D-C028D6348094@gmail.com> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) Subject: Re: [PATCH] Clear out gfxterm's virtual text_buffer - fixes junk at end of lines X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2009 18:04:22 -0000 On Wed, Jul 22, 2009 at 10:42:54AM -0700, Joe Auricchio wrote: > > On 22 Jul, 2009, at 10:27 , Robert Millan wrote: > >> On Sat, Jul 18, 2009 at 03:39:00PM -0700, Joe Auricchio wrote: >>> >>> On 18 Jul, 2009, at 11:58 , Robert Millan wrote: >>>> On Sat, Jul 18, 2009 at 12:15:04AM -0700, Joe Auricchio wrote: >>>>> >>>>> This fixes a 100% reproducible and very annoying bug I've found: >>>>> Switch >>>>> to gfxterm and until your clear the screen or scroll, the last >>>>> position >>>>> of every line has a random junk character in random foreground and >>>>> background color. I believe the root cause is that the >>>>> virtual_screen's >>>>> text_buffer is uninitialized; as the cursor reaches a new position, >>>>> the >>>>> uninitialized junk data is drawn to the screen. Really, the entire >>>>> screen >>>>> is junk, but it's never marked dirty so it's never drawn. So let's >>>>> just >>>>> clear out the whole text_buffer when we set up the screen. >>>> >>>> But grub_virtual_screen_free() already set the whole structure to >>>> 0 at >>>> the >>>> beginning of grub_virtual_screen_setup(). >>>> >>>> Does a zero-filled screen result in garbage, or is something else >>>> overwriting >>>> it? >>> >>> grub_virtual_screen_free sets all of virtual_screen to 0, but not >>> virtual_screen.text_buffer. text_buffer just gets grub_freed. Later >>> in >>> grub_virtual_screen_setup, a new text_buffer is grub_malloced. It's >>> this >>> new text_buffer that my patch clears out. >> >> So perhaps this can be solved simpler by replacing grub_malloc with >> grub_zalloc ? > > I saw the zalloc commit and thought the same thing! :D I'll test it. But > fg_color and bg_color must be set to the screen's current colors, which > may not be zero. > > I just discovered that > - this patch to grub_virtual_screen_setup() > - scroll_up() line 579 /* Clear last line in text buffer. */, and > - grub_virtual_screen_cls() > do the same thing. > > An opportunity to refactor? I'll look into this. Please do. We're very interested in code cleanup. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."