bug-grub
[Top][All Lists]
Advanced

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

[PATCH] Bug in multiboot loader


From: kashyap garimella
Subject: [PATCH] Bug in multiboot loader
Date: Thu, 16 Dec 2010 03:09:47 +0530

Hello everybody,

I have tried to boot Invaders, a small multiboot compliant kernel game, and found that it was not working(triple faults). After a lot of painful debugging, I found the bug in grub-core/loader/i386/multiboot_mbi.c. Here is the patch:
=== modified file 'grub-core/loader/i386/multiboot_mbi.c'
--- grub-core/loader/i386/multiboot_mbi.c    2010-09-29 21:51:12 +0000
+++ grub-core/loader/i386/multiboot_mbi.c    2010-12-15 21:25:52 +0000
@@ -141,7 +141,7 @@
     }
 
       if (header->bss_end_addr)
-    grub_memset ((grub_uint32_t *) source + load_size, 0,
+    grub_memset ((grub_uint8_t *) source + load_size, 0,
              header->bss_end_addr - header->load_addr - load_size);
 
       grub_multiboot_payload_eip = header->entry_addr;


--
The bug is very simple, but tough to find. "(grub_uint32_t *) source + load_size" will give the resultant address as "source + 4 * load_size", since source is made 32-bit pointer. But it is wrong because load_size is the size in bytes. So "source" should also be treated in bytes, i.e. grub_uint8_t. Hence a single line fix will solve the problem. Pfa the patch file. I have read the multiboot specs from here. I have used grub_printf to debug. I would like to know if there is any better debugging technique for memory debugging.

Thanks,
Kashyap Garimella

Attachment: patch
Description: Binary data


reply via email to

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