bug-parted
[Top][All Lists]
Advanced

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

Re: Bug in parted with GPT partition table from Lenovo Ideapad A1


From: Jim Meyering
Subject: Re: Bug in parted with GPT partition table from Lenovo Ideapad A1
Date: Fri, 30 Dec 2011 21:04:57 +0100

Markall, Graham wrote:
> I'm trying to use gparted to examine what I believe is a partition table from 
> the Lenovo Ideapad A1. I've uploded a file containing the partition table to 
> http://www.doc.ic.ac.uk/~grm08/ideapad/mbr16GB.img (md5: 
> 0b236b16e98de53393f6539c40ba1201).
>
> When I use the command "print all", there are a couple of errors that I have 
> to ignore, and then a failed assertion. The output is as follows:
>
> $ parted mbr16GB.img
> GNU Parted 3.0
> Using /home/graham/android/ideapad_ota/ROW/mbr16GB.img
> Welcome to GNU Parted! Type 'help' to view a list of commands.
> (parted) print all
> Error: end of file while reading No medium found
> Retry/Ignore/Cancel? i
> Error: The backup GPT table is corrupt, but the primary appears OK, so that 
> will be used.
> OK/Cancel? OK
> Backtrace has 10 calls on stack:
>   10: /home/graham/programs/parted-3.0/lib/libparted.so.1(ped_assert+0x2e) 
> [0x7f44f40d470e]
>   9: /home/graham/programs/parted-3.0/lib/libparted.so.1(+0x2596a) 
> [0x7f44f40ec96a]
>   8: /home/graham/programs/parted-3.0/lib/libparted.so.1(ped_disk_new+0x58) 
> [0x7f44f40d9b88]
>   7: /home/graham/programs/parted-3.0/sbin/parted() [0x406af1]
>   6: /home/graham/programs/parted-3.0/sbin/parted() [0x4075ca]
>   5: /home/graham/programs/parted-3.0/sbin/parted() [0x407585]
>   4: /home/graham/programs/parted-3.0/sbin/parted(interactive_mode+0xf3) 
> [0x40bf03]
>   3: /home/graham/programs/parted-3.0/sbin/parted(main+0xe47) [0x406047]
>   2: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd) [0x7f44f38d4ead]
>   1: /home/graham/programs/parted-3.0/sbin/parted() [0x4060d5]
>
>
> You found a bug in GNU Parted! Here's what you have to do:
>
> ...
>
> Assertion (last_usable <= disk->dev->length) at gpt.c:727 in function 
> _parse_header() failed.
>
>
>
>
>
> The output of "parted DEVICE unit co print unit s print" was as follows:
>
> $ parted mbr16GB.img unit co print unit s print
> Error: end of file while reading No such file or directory
> parted: invalid token: unit
> Retry/Ignore/Cancel? i
> Error: The backup GPT table is corrupt, but the primary appears OK, so that 
> will be used.
> OK/Cancel? OK
> Backtrace has 8 calls on stack:
>   8: /lib/x86_64-linux-gnu/libparted.so.0(ped_assert+0x2e) [0x7f00cfaa1f3e]
>   7: /lib/x86_64-linux-gnu/libparted.so.0(+0x44712) [0x7f00cfad2712]
>   6: /lib/x86_64-linux-gnu/libparted.so.0(ped_disk_new+0x58) [0x7f00cfaa80b8]
>   5: parted() [0x407401]
>   4: parted(non_interactive_mode+0x8c) [0x40e00c]
>   3: parted(main+0x1407) [0x406ae7]
>   2: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd) [0x7f00cf29bead]
>   1: parted() [0x406bad]

Thanks for reporting that.
Here are two related patches.
Either in isolation should avoid that failed assertion.
I'll probably write a test to demonstrate, eventually.


>From 7719b450b0a93863039bef3cfc142dfdfedbc930 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 30 Dec 2011 20:43:33 +0100
Subject: [PATCH 1/2] libparted: do not offer "ignore" as an option upon read
 failure

* libparted/arch/linux.c (linux_read): Do not allow an interactive
user to ignore "EOF while reading".  That would lead to a failed
assertion.  Reported by Graham Markall in
http://thread.gmane.org/gmane.comp.gnu.parted.bugs/10653
---
 libparted/arch/linux.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 39372bb..c43d590 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1762,7 +1762,7 @@ linux_read (const PedDevice* dev, void* buffer, PedSector 
start,

                 ex_status = ped_exception_throw (
                         PED_EXCEPTION_ERROR,
-                        PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+                        PED_EXCEPTION_RETRY_CANCEL,
                         (status == 0
                          ? _("%0.0send of file while reading %s")
                          : _("%s during read on %s")),
@@ -1770,10 +1770,6 @@ linux_read (const PedDevice* dev, void* buffer, 
PedSector start,
                         dev->path);

                 switch (ex_status) {
-                        case PED_EXCEPTION_IGNORE:
-                                free(diobuf);
-                                return 1;
-
                         case PED_EXCEPTION_RETRY:
                                 break;

--
1.7.8.1.391.g2c2ad


>From 16f02f6891880cd0055a2678da17db6d7c7ae816 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 30 Dec 2011 21:03:06 +0100
Subject: [PATCH 2/2] gpt: eliminate four PED_ASSERT uses

* libparted/labels/gpt.c (_parse_header): Convert a few PED_ASSERT
uses to friendlier 'test-and-return-0's.
---
 libparted/labels/gpt.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 9d464c6..b812c4a 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -728,19 +728,18 @@ _parse_header (PedDisk *disk, const 
GuidPartitionTableHeader_t *gpt,
     GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / disk->dev->sector_size;

   if (last_usable_if_grown > last_usable_min_default)
-    {
-      last_usable_if_grown = last_usable_min_default;
-    }
+    last_usable_if_grown = last_usable_min_default;

-  PED_ASSERT (last_usable > first_usable);
-  PED_ASSERT (last_usable <= disk->dev->length);
+  if (last_usable <= first_usable
+      || disk->dev->length < last_usable)
+    return 0;

-  PED_ASSERT (last_usable_if_grown > first_usable);
-  PED_ASSERT (last_usable_if_grown <= disk->dev->length);
+  if (last_usable_if_grown <= first_usable
+      || disk->dev->length < last_usable_if_grown)
+    return 0;

   if (!asked_already && last_usable < last_usable_if_grown)
     {
-
       PedExceptionOption q;

       q = ped_exception_throw
--
1.7.8.1.391.g2c2ad



reply via email to

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