From: Joel Buckley <leojava@comcast.net>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: problem in usage of grub_errno...
Date: Sun, 18 Dec 2005 22:15:27 -0700 [thread overview]
Message-ID: <43A641EF.3040909@comcast.net> (raw)
In-Reply-To: <43A49C6B.1080408@nic.fi>
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
>
>
>
next prev parent reply other threads:[~2005-12-19 5:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-09 21:58 problem in usage of grub_errno Vesa Jääskeläinen
2005-12-09 22:29 ` Marco Gerards
2005-12-10 10:05 ` Vesa Jääskeläinen
2005-12-10 13:11 ` Yoshinori K. Okuji
2005-12-10 20:12 ` Vesa Jääskeläinen
2005-12-17 17:40 ` Vesa Jääskeläinen
2005-12-17 22:59 ` Tomáš Ebenlendr
2005-12-17 23:16 ` Vesa Jääskeläinen
2005-12-19 5:15 ` Joel Buckley [this message]
2005-12-19 15:35 ` Vesa Jääskeläinen
2005-12-19 8:37 ` Tomáš Ebenlendr
2005-12-19 15:42 ` Vesa Jääskeläinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43A641EF.3040909@comcast.net \
--to=leojava@comcast.net \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.