#819488 gparted crash with a libparted backtrace

#819488#5
Date:
2016-03-29 12:49:15 UTC
From:
To:
mattia@chase ~ % gksudo gparted
======================
libparted : 3.2
======================
Backtrace has 16 calls on stack:
  16: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x44) [0x7fc5feb2eae4]
  15: /lib/x86_64-linux-gnu/libparted.so.2(+0x2009f) [0x7fc5feb4209f]
  14: /lib/x86_64-linux-gnu/libparted.so.2(+0x114fa) [0x7fc5feb334fa]
  13: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_add_partition+0x25f) [0x7fc5feb33def]
  12: /lib/x86_64-linux-gnu/libparted.so.2(+0x1f98f) [0x7fc5feb4198f]
  11: /lib/x86_64-linux-gnu/libparted.so.2(+0x1fa20) [0x7fc5feb41a20]
  10: /lib/x86_64-linux-gnu/libparted.so.2(+0x1fa20) [0x7fc5feb41a20]
  9: /lib/x86_64-linux-gnu/libparted.so.2(+0x1f9c9) [0x7fc5feb419c9]
  8: /lib/x86_64-linux-gnu/libparted.so.2(+0x209b5) [0x7fc5feb429b5]
  7: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_new+0x48) [0x7fc5feb33a18]
  6: /usr/sbin/gpartedbin() [0x466bfe]
  5: /usr/sbin/gpartedbin() [0x47554e]
  4: /usr/lib/x86_64-linux-gnu/libglibmm-2.4.so.1(+0x51c3d) [0x7fc600043c3d]
  3: /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x70b75) [0x7fc5feff7b75]
  2: /lib/x86_64-linux-gnu/libpthread.so.0(+0x7454) [0x7fc5fde78454]
  1: /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fc5fdbb5edd]


And quit here, funnily exiting with 0 (e.g. successfully).

Now, unhelpfully the maintainer did a binary upload, either built with
an outdated chroot or by manually disabling the automatic debug
packages, but given that probably the issue is in libparted2, and luckiy
the parted's maintainer does source uploads, and built the debug
package, I installed libparted2-dbgsym, and run the this in gdb to have
a backtrace, here follows the whole thing.

I don't know if the issue actually lies, so maybe this bug should be
reassigned to libparted2 instead.

Please tell me if you would be helped by more information.

mattia@chase ~ % sudo gdb /usr/sbin/gpartedbin
GNU gdb (Debian 7.10-1+b1) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/gpartedbin...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/sbin/gpartedbin
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
======================
libparted : 3.2
======================
[New Thread 0x7fffee642700 (LWP 19548)]
[New Thread 0x7fffeda6b700 (LWP 19554)]
Backtrace has 16 calls on stack:
  16: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x44) [0x7ffff5993ae4]
  15: /lib/x86_64-linux-gnu/libparted.so.2(+0x2009f) [0x7ffff59a709f]
  14: /lib/x86_64-linux-gnu/libparted.so.2(+0x114fa) [0x7ffff59984fa]
  13: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_add_partition+0x25f) [0x7ffff5998def]
  12: /lib/x86_64-linux-gnu/libparted.so.2(+0x1f98f) [0x7ffff59a698f]
  11: /lib/x86_64-linux-gnu/libparted.so.2(+0x1fa20) [0x7ffff59a6a20]
  10: /lib/x86_64-linux-gnu/libparted.so.2(+0x1fa20) [0x7ffff59a6a20]
  9: /lib/x86_64-linux-gnu/libparted.so.2(+0x1f9c9) [0x7ffff59a69c9]
  8: /lib/x86_64-linux-gnu/libparted.so.2(+0x209b5) [0x7ffff59a79b5]
  7: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_new+0x48) [0x7ffff5998a18]
  6: /usr/sbin/gpartedbin() [0x466bfe]
  5: /usr/sbin/gpartedbin() [0x47554e]
  4: /usr/lib/x86_64-linux-gnu/libglibmm-2.4.so.1(+0x51c3d) [0x7ffff6ea8c3d]
  3: /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x70b75) [0x7ffff5e5cb75]
  2: /lib/x86_64-linux-gnu/libpthread.so.0(+0x7454) [0x7ffff4cdd454]
  1: /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7ffff4a1aedd]
Assertion (metadata_length > 0) at ../../../libparted/labels/dos.c:2313 in function add_logical_part_metadata() failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffeda6b700 (LWP 19554)]
0x00007ffff4965478 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
55	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff4965478 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1  0x00007ffff49668fa in __GI_abort () at abort.c:89
#2  0x00007ffff5993b9c in ped_assert (cond_text=cond_text@entry=0x7ffff59becce "metadata_length > 0",
    file=file@entry=0x7ffff59beac0 "../../../libparted/labels/dos.c", line=line@entry=2313,
    function=function@entry=0x7ffff59bf040 <__PRETTY_FUNCTION__.5892> "add_logical_part_metadata") at ../../libparted/debug.c:111
#3  0x00007ffff59a709f in add_logical_part_metadata (log_part=0x7fffe0005b30, disk=0x7fffe00008c0) at ../../../libparted/labels/dos.c:2313
#4  msdos_alloc_metadata (disk=0x7fffe00008c0) at ../../../libparted/labels/dos.c:2444
#5  0x00007ffff59984fa in _disk_alloc_metadata (disk=0x7fffe00008c0) at ../../libparted/disk.c:1011
#6  _disk_pop_update_mode (disk=0x7fffe00008c0) at ../../libparted/disk.c:1164
#7  0x00007ffff5998def in ped_disk_add_partition (disk=disk@entry=0x7fffe00008c0, part=part@entry=0x7fffe0005b30, constraint=0x7fffe0005740,
    constraint@entry=0x7fffe0005c70) at ../../libparted/disk.c:1993
#8  0x00007ffff59a698f in read_table (disk=disk@entry=0x7fffe00008c0, sector=1873516365, is_extended_table=is_extended_table@entry=1)
    at ../../../libparted/labels/dos.c:1055
#9  0x00007ffff59a6a20 in read_table (disk=disk@entry=0x7fffe00008c0, sector=2047, is_extended_table=is_extended_table@entry=1) at ../../../libparted/labels/dos.c:1085
#10 0x00007ffff59a6a20 in read_table (disk=disk@entry=0x7fffe00008c0, sector=2046, is_extended_table=is_extended_table@entry=1) at ../../../libparted/labels/dos.c:1085
#11 0x00007ffff59a69c9 in read_table (disk=disk@entry=0x7fffe00008c0, sector=sector@entry=0, is_extended_table=is_extended_table@entry=0)
    at ../../../libparted/labels/dos.c:1062
#12 0x00007ffff59a79b5 in msdos_read (disk=0x7fffe00008c0) at ../../../libparted/labels/dos.c:1107
#13 0x00007ffff5998a18 in ped_disk_new (dev=0x7fffe0003e70) at ../../libparted/disk.c:201
#14 0x0000000000466bfe in ?? ()
#15 0x000000000047554e in ?? ()
#16 0x00007ffff6ea8c3d in ?? () from /usr/lib/x86_64-linux-gnu/libglibmm-2.4.so.1
#17 0x00007ffff5e5cb75 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#18 0x00007ffff4cdd454 in start_thread (arg=0x7fffeda6b700) at pthread_create.c:334
#19 0x00007ffff4a1aedd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) k
Kill the program being debugged? (y or n) y
(gdb) q
mattia@chase ~ %

#819488#10
Date:
2016-04-11 17:06:14 UTC
From:
To:
Would you be able to provide the output from the following two commands?

    sudo fdisk -l -u

  where one of the options is a lower case "L" and not the number one.

    sudo parted /path-to-your-device unit s print

  where /path-to-your-device is something like /dev/sda.

I expect that latter command to fail if the problem is indeed in the
libparted library.

Regards,
Curtis

#819488#15
Date:
2016-04-11 17:06:14 UTC
From:
To:
Would you be able to provide the output from the following two commands?

    sudo fdisk -l -u

  where one of the options is a lower case "L" and not the number one.

    sudo parted /path-to-your-device unit s print

  where /path-to-your-device is something like /dev/sda.

I expect that latter command to fail if the problem is indeed in the
libparted library.

Regards,
Curtis

#819488#20
Date:
2016-04-11 17:42:10 UTC
From:
To:
control: reassign -1 src:parted 3.2-15

sure thing :)
[sudo] password for mattia:
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xbfbc6f0d

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sda1  *          2046 1953523711 1953521666 931.5G  5 Extended
/dev/sda5             2048  999999487  999997440 476.9G 83 Linux
/dev/sda6       1873524736 1933524991   60000256  28.6G 83 Linux
/dev/sda7       1933524992 1953523711   19998720   9.5G 82 Linux swap / Solaris

Partition 1 does not start on physical sector boundary.




Disk /dev/mapper/home: 476.9 GiB, 511996592128 bytes, 999993344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Backtrace has 15 calls on stack:
  15: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x44) [0x7f79c46fbae4]
  14: /lib/x86_64-linux-gnu/libparted.so.2(+0x2009f) [0x7f79c470f09f]
  13: /lib/x86_64-linux-gnu/libparted.so.2(+0x114fa) [0x7f79c47004fa]
  12: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_add_partition+0x25f) [0x7f79c4700def]
  11: /lib/x86_64-linux-gnu/libparted.so.2(+0x1f98f) [0x7f79c470e98f]
  10: /lib/x86_64-linux-gnu/libparted.so.2(+0x1fa20) [0x7f79c470ea20]
  9: /lib/x86_64-linux-gnu/libparted.so.2(+0x1fa20) [0x7f79c470ea20]
  8: /lib/x86_64-linux-gnu/libparted.so.2(+0x1f9c9) [0x7f79c470e9c9]
  7: /lib/x86_64-linux-gnu/libparted.so.2(+0x209b5) [0x7f79c470f9b5]
  6: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_new+0x48) [0x7f79c4700a18]
  5: parted(+0x7343) [0x56338d485343]
  4: parted(non_interactive_mode+0x92) [0x56338d48b102]
  3: parted(main+0x1238) [0x56338d484028]
  2: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f79c3ef7610]
  1: parted(_start+0x29) [0x56338d4841d9]


You found a bug in GNU Parted! Here's what you have to do:

Don't panic! The bug has most likely not affected any of your data.
Help us to fix this bug by doing the following:

Check whether the bug has already been fixed by checking
the last version of GNU Parted that you can find at:

http://ftp.gnu.org/gnu/parted/

Please check this version prior to bug reporting.

If this has not been fixed yet or if you don't know how to check,
please visit the GNU Parted website:

http://www.gnu.org/software/parted

for further information.

Your report should contain the version of this release (3.2)
along with the error message below, the output of

	parted DEVICE unit co print unit s print

and the following history of commands you entered.
Also include any additional information about your setup you
consider important.

Assertion (metadata_length > 0) at ../../../libparted/labels/dos.c:2313 in function add_logical_part_metadata() failed.

[1]    17350 abort      sudo parted /dev/sda unit s print
134 mattia@chase ~ %

(134 is the return code)

So, it seems it is :)

Reassigning to src:parted.

#819488#31
Date:
2016-04-11 17:52:32 UTC
From:
To:

If I recall correctly, libparted was not able to handle when there was
only one unallocated sector between logical partitions (it expects at
least two).

In your situation there is only one unallocated sector between the end
of sda6 and the start of sda7.  The unallocated sector is used to store
the Extended Boot Record for a logical partition.

To work around the problem you might consider deleting the Linux Swap
sda7 partition using fdisk.

Next you could recreate the Linux Swap making sure to leave at least two
unallocated sectors after sda6.  Then you would need to ensure that the
UUID for the Linux Swap matched the value in /etc/fstab so that it would
automatically be mounted at boot time.

Regards,
Curtis

#819488#36
Date:
2016-04-11 18:13:06 UTC
From:
To:
well, that's really not a reason to crash like that! ;)

yes, I could recreate the swap partition.  now, I'm not in hurry to
havev gparted working, so I'm just gonna postpone this till I either
need it, or if you need a confirmation that's the issue (but then I
won't be able to test a fix, etc).

Yeah, I have a vague idea about partitions and /etc/fstab ;)

#819488#41
Date:
2016-04-12 01:00:41 UTC
From:
To:
I believe that is exactly it Curtis.

For the last 3 decades, it has not been a problem since every disk
partitioner has worked this way.  I have sen a few bug reports about
this recently though, and the others have reported using something
called Easeus disk partitioning software.  Have you used this?  It
would be good to confirm this is the source of the problem and I'll
see if I can't fix parted to handle it.

#819488#46
Date:
2016-04-12 15:52:02 UTC
From:
To:
good to know I'm not the only one!  I was in fact quite uneasy seeing
there were no reports in the BTS. :)

never heard of this thing.

tbh, I experienced this crash since quite some time, but I was always
too lazy to open a bug.
I have this hard disc with this partitioning since Feb 2015, and never
changed anything since then.

I don't recall how I made the partitions, sorry, but for sure I haven't
used that software I've never heard about.

#819488#51
Date:
2016-11-03 15:37:02 UTC
From:
To:
Phillip, did you have a chance to look at making parted not crashing
if there is only one unallocated sector between partitions? Mattia, do
you still consider this bug RC? thanks!

#819488#54
Date:
2016-11-03 17:48:56 UTC
From:
To:
I don't think so, no.  Though it's still a crash, it's important, but
probably not RC indeed.

Furthermore I'm not affected by this anymore, since I "fixed" my
partition table to have libparted like it more.

#819488#59
Date:
2016-11-03 20:34:33 UTC
From:
To:
I have not had time to work on it yet.
#819488#64
Date:
2016-11-03 21:17:53 UTC
From:
To:
control: severity -1 important

yup agreed on this, setting the severity accordingly

no worries!

#819488#71
Date:
2018-06-12 02:42:12 UTC
From:
To:
I also confirm this bug still exists. Here is the output of

# fdisk -l -u /dev/sda
Disk /dev/sda: 465,8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x1baf0215

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sda1           2048  10567679  10565632     5G 83 Linux
/dev/sda3  *    10567680  31930287  21362608  10,2G 83 Linux
/dev/sda4       31930366 976771071 944840706 450,5G  5 Extended
/dev/sda5  *    31932416  48338943  16406528   7,8G 83 Linux
/dev/sda6       48338944  52535295   4196352     2G 82 Linux swap / Solaris
/dev/sda7       52537344 976771071 924233728 440,7G 83 Linux

Partition 4 does not start on physical sector boundary.

Indeed, there is no unallocated sector between my logical partitions
sda5 and sda6.
  If I recall correctly, I have used only fdisk, cfdisk and/or Debian/Ubuntu
installers (using parted itself?) to manipulate the partition table.
I have not used any Windows tool.

Here upstream maintainers discuss if it is actually a bug:
https://lists.gnu.org/archive/html/bug-parted/2015-09/msg00021.html
I also consider it an important bug. (Any program aborting and suggesting
to report a bug instead of executing a basic functionality, by definiton,
has a bug.) Parted should instead handle the partition table and give a
warning about the non-standard EBR arrangement. Or if it cannot be made
robust enough to handle such partition table (though, this does not look
impossible), it should at least give a proper error message about that,
rather than abort with a failure.

Btw, there are now quite a lot reports about this:
https://google.com/search?q=Assertion+add_logical_part_metadata+failed ,
some of which blaming parted of fdisk for the "non-standard" EBR arrangement,
e.g.:
https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1543704/comments/13
https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1543704/comments/14

Is there any advance with the fix? Is there plans for a new upstream release?

FYI, here is the output of
# parted /dev/sda print
and
# parted /dev/sda unit co print unit s print
Backtrace has 14 calls on stack:
   14: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x45) [0x7fd2a2274fc5]
   13: /lib/x86_64-linux-gnu/libparted.so.2(+0x23b3f) [0x7fd2a228bb3f]
   12: /lib/x86_64-linux-gnu/libparted.so.2(+0x119fa) [0x7fd2a22799fa]
   11: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_add_partition+0x283) [0x7fd2a227a313]
   10: /lib/x86_64-linux-gnu/libparted.so.2(+0x233ec) [0x7fd2a228b3ec]
   9: /lib/x86_64-linux-gnu/libparted.so.2(+0x23480) [0x7fd2a228b480]
   8: /lib/x86_64-linux-gnu/libparted.so.2(+0x23426) [0x7fd2a228b426]
   7: /lib/x86_64-linux-gnu/libparted.so.2(+0x24455) [0x7fd2a228c455]
   6: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_new+0x48) [0x7fd2a2279f18]
   5: parted(+0x73fe) [0x55a4b69f33fe]
   4: parted(non_interactive_mode+0x92) [0x55a4b69f91c2]
   3: parted(main+0x12bf) [0x55a4b69f207f]
   2: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7fd2a1a722e1]
   1: parted(_start+0x2a) [0x55a4b69f224a]


You found a bug in GNU Parted! Here's what you have to do:

Don't panic! The bug has most likely not affected any of your data.
Help us to fix this bug by doing the following:

Check whether the bug has already been fixed by checking
the last version of GNU Parted that you can find at:

http://ftp.gnu.org/gnu/parted/

Please check this version prior to bug reporting.

If this has not been fixed yet or if you don't know how to check,
please visit the GNU Parted website:

http://www.gnu.org/software/parted

for further information.

Your report should contain the version of this release (3.2)
along with the error message below, the output of

         parted DEVICE unit co print unit s print

and the following history of commands you entered.
Also include any additional information about your setup you
consider important.

Assertion (metadata_length > 0) at ../../../libparted/labels/dos.c:2313 in
function add_logical_part_metadata() failed.

Aborted
-----------
And here is the first 4 sectors of my extended partition (with EBRs?)
omitting the 0-only lines:

# dd if=/dev/sda skip=31930366 count=4 2>/dev/null|xxd |grep -v "0000 0000 0000 0000 0000 0000 0000 0000"

000001b0: 0000 0000 0000 0000 0000 0000 0000 80b2  ................
000001c0: f0c3 83f4 f4c0 0208 0000 0058 fa00 0092  ...........X....
000001d0: d0c3 052b 25c6 0200 0000 0068 3a01 0000  ...+%......h:...

000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.

000005b0: 0000 0000 0000 0000 0000 0000 0000 00fe  ................
000005c0: ffff 82fe ffff 0060 fa00 0008 4000 002b  .......`....@..+
000005d0: 26c6 052f 6e81 0268 3a01 00b8 1637 0000  &../n..h:....7..

000005f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.


Thanks,
Andras

#819488#76
Date:
2024-05-11 01:05:45 UTC
From:
To:
Hi There,
Good day!
This is Andy from China, a Chair Product manufacturer in China,
About you are in the same market, I thought there might be a good fit for your business.
We have the good quality products selling mega promotion price.

Welcome to enquiry. I will after getting the information, send you a best price.
With my best regards,
Andy