grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem in usage of grub_errno...


From: Joel Buckley
Subject: Re: problem in usage of grub_errno...
Date: Sun, 18 Dec 2005 22:15:27 -0700
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

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
address@hidden
http://lists.gnu.org/mailman/listinfo/grub-devel






reply via email to

[Prev in Thread] Current Thread [Next in Thread]