From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1EoDNw-0003wE-Hc for mharc-grub-devel@gnu.org; Mon, 19 Dec 2005 00:16:32 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EoDNu-0003w9-Ve for grub-devel@gnu.org; Mon, 19 Dec 2005 00:16:31 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EoDNt-0003vu-CO for grub-devel@gnu.org; Mon, 19 Dec 2005 00:16:30 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EoDNt-0003vr-9h for grub-devel@gnu.org; Mon, 19 Dec 2005 00:16:29 -0500 Received: from [216.148.227.152] (helo=rwcrmhc12.comcast.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EoDQm-0000fi-JB for grub-devel@gnu.org; Mon, 19 Dec 2005 00:19:28 -0500 Received: from [192.168.15.100] (c-67-190-123-113.hsd1.co.comcast.net[67.190.123.113]) by comcast.net (rwcrmhc12) with ESMTP id <2005121905153501400aa5u2e>; Mon, 19 Dec 2005 05:15:36 +0000 Message-ID: <43A641EF.3040909@comcast.net> Date: Sun, 18 Dec 2005 22:15:27 -0700 From: Joel Buckley User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <4399FE01.7010402@nic.fi> <87mzj9q4z7.fsf@xs4all.nl> <439AA87B.9050607@nic.fi> <200512101411.11612.okuji@enbug.org> <439B369D.7020909@nic.fi> <43A44DA4.5090601@nic.fi> <1652.62.240.162.34.1134860376.squirrel@drak.ucw.cz> <43A49C6B.1080408@nic.fi> In-Reply-To: <43A49C6B.1080408@nic.fi> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: problem in usage of grub_errno... 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: Mon, 19 Dec 2005 05:16:31 -0000 There is a second bug though... A possible stack memory-leak is possible. Replace the first line with the following to avoid the memory leak: if (grub_errno != GRUB_ERR_NONE) { grub_error_push(); } Otherwise, a useless push is done. leoJ. Vesa Jääskeläinen wrote: >Tomá¹ Ebenlendr wrote: > > >>I think there is a 'bug' in the example. Or maybe I'm missing something. >> >> > >Nope, it was intentional. :) > > > >>On 17 Prosinec 2005, 18:40, Vesa Jääskeläinen napsal(a): >>.... >> >> >>>--- >>>/* Save possible old error message. */ >>>grub_error_push (); >>> >>>/* Do your stuff here. */ >>>call_possibly_failing_function (); >>> >>>if (grub_errno != GRUB_ERR_NONE) >>> { >>> /* Inform rest of the code that there is error (grub_errno >>> is set). */ >>> return; >>> } >>> >>>/* Restore old error state by popping previous item from stack. */ >>>grub_error_pop (); >>>--- >>> >>> >>.... >> >>When grub_errno != GRUB_ERR_NONE (branching into the 'if'), then >>there is no grub_error_pop() in the example. >>If the whole thing will be called in a loop, then unwanted >>stack overflow can simply occur. >> >> > >Error stack is statically allocated and it is protected so that it >cannot overflow. Error stack is defined as being static to file >kern/err.c so there is no direct access possible to error stack. > >Error stack is emptied in grub_print_error function. (And this is called >before prompt is printed to screen) > >Idea of the error stack is to record all error messages before they are >printed. > >Or did I miss your idea with the "unwanted stack overflow" ? > >Thanks, >Vesa Jääskeläinen > > >_______________________________________________ >Grub-devel mailing list >Grub-devel@gnu.org >http://lists.gnu.org/mailman/listinfo/grub-devel > > >