#981692 parted: crash when printing device partitions

Package:
parted
Source:
parted
Description:
disk partition manipulator
Submitter:
Eric Valette
Date:
2021-02-21 11:24:04 UTC
Severity:
important
#981692#5
Date:
2021-02-02 22:23:47 UTC
From:
To:
parted /dev/sdb
GNU Parted 3.4
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
  align-check TYPE N                       check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) print
Backtrace has 14 calls on stack:
  14: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x45) [0x7f42e4569c85]
  13: /lib/x86_64-linux-gnu/libparted.so.2(+0x267e7) [0x7f42e45817e7]
  12: /lib/x86_64-linux-gnu/libparted.so.2(+0x1369a) [0x7f42e456e69a]
  11: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_add_partition+0x1bc) [0x7f42e456ef3c]
  10: /lib/x86_64-linux-gnu/libparted.so.2(+0x27295) [0x7f42e4582295]
  9: /lib/x86_64-linux-gnu/libparted.so.2(+0x27447) [0x7f42e4582447]
  8: /lib/x86_64-linux-gnu/libparted.so.2(+0x272d9) [0x7f42e45822d9]
  7: /lib/x86_64-linux-gnu/libparted.so.2(+0x27501) [0x7f42e4582501]
  6: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_new+0x48) [0x7f42e456e9f8]
  5: parted(+0x8b29) [0x5618f9641b29]
  4: parted(interactive_mode+0x187) [0x5618f96473a7]
  3: parted(main+0x1376) [0x5618f963fdd6]
  2: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7f42e4336d0a]
  1: parted(_start+0x2a) [0x5618f963fe5a]


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.4)
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:2359 in function add_logical_part_metadata() failed.

Aborted
root@tri-yann4:~# parted /dev/sdb unit co print unit s print
Backtrace has 14 calls on stack:
  14: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x45) [0x7efefbf72c85]
  13: /lib/x86_64-linux-gnu/libparted.so.2(+0x267e7) [0x7efefbf8a7e7]
  12: /lib/x86_64-linux-gnu/libparted.so.2(+0x1369a) [0x7efefbf7769a]
  11: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_add_partition+0x1bc) [0x7efefbf77f3c]
  10: /lib/x86_64-linux-gnu/libparted.so.2(+0x27295) [0x7efefbf8b295]
  9: /lib/x86_64-linux-gnu/libparted.so.2(+0x27447) [0x7efefbf8b447]
  8: /lib/x86_64-linux-gnu/libparted.so.2(+0x272d9) [0x7efefbf8b2d9]
  7: /lib/x86_64-linux-gnu/libparted.so.2(+0x27501) [0x7efefbf8b501]
  6: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_new+0x48) [0x7efefbf779f8]
  5: parted(+0x8b29) [0x55e3bf3dab29]
  4: parted(non_interactive_mode+0xb8) [0x55e3bf3e0518]
  3: parted(main+0x1265) [0x55e3bf3d8cc5]
  2: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7efefbd3fd0a]
  1: parted(_start+0x2a) [0x55e3bf3d8e5a]


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.4)
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:2359 in function add_logical_part_metadata() failed.

Aborted

#981692#10
Date:
2021-02-03 10:04:36 UTC
From:
To:
sfdisk -V /dev/sdb
/dev/sdb:
No errors detected.
Remaining 13226 unallocated 512-byte sectors.

sfdisk -d /dev/sdb > my_disk_partition.txt

more my_disk_partition.txt
label: dos
label-id: 0x0006411f
device: /dev/sdb
unit: sectors
sector-size: 512

/dev/sdb1 : start=        2048, size=   117184512, type=7, bootable
/dev/sdb3 : start=   117188606, size=   117252098, type=5
/dev/sdb5 : start=   117190656, size=    41013248, type=83
/dev/sdb6 : start=   158203904, size=     9762816, type=83
/dev/sdb7 : start=   167968768, size=    13670400, type=83
/dev/sdb8 : start=   181641216, size=     1951744, type=83
/dev/sdb9 : start=   183595008, size=    39059456, type=83
/dev/sdb10 : start=   222656512, size=    11784192, type=82

To recreate an identically partitionned disk

you can recreate the same disk format via:

sfdisk /dev/sdb < my_disk_partition.txt

#981692#15
Date:
2021-02-03 15:14:43 UTC
From:
To:
When I tried to recreate this, sfdisk gave me an error that the
numerical result was out of range.  When I looked closely at the
numbers, it appears that you have no space between partitions 5 and 6,
so there is no room to place the EBR.  Do you know how you managed to
generate a partition table that is broken in this way?

#981692#20
Date:
2021-02-03 16:34:10 UTC
From:
To:
Its and very old SSD that has been partitionned at time where thedefault
1MiB space limit between partition was was no there. Apart that I did
partition probably usinf cfisk at that time.

What is strange is that in my case sfdisk -V reports no error and the
partitions are correctly detected so the EBR are obviously stored...


I guess that it happens that the default size for sfdisk "grain" value
(see man sfdisk) has chnaged from one sector to one MiB. I created the
following output. see the gain value below.

more my_disk_partition.txt
label: dos
label-id: 0x0006411f
device: /dev/sdb
unit: sectors
sector-size: 512
gain: 512

/dev/sdb1 : start=        2048, size=   117184512, type=7, bootable
/dev/sdb3 : start=   117188606, size=   117252098, type=5
/dev/sdb5 : start=   117190656, size=    41013248, type=83
/dev/sdb6 : start=   158203904, size=     9762816, type=83
/dev/sdb7 : start=   167968768, size=    13670400, type=83
/dev/sdb8 : start=   181641216, size=     1951744, type=83
/dev/sdb9 : start=   183595008, size=    39059456, type=83
/dev/sdb10 : start=   222656512, size=    11784192, type=82

To recreate an identically partitionned disk

you can recreate the same disk format via:

sfdisk /dev/sdb < my_disk_partition.txt

#981692#25
Date:
2021-02-03 19:22:22 UTC
From:
To:
Eric Valette writes:

It is theretically possible to say, store multipe EBRs in the start of
the extended partition before the first logical partition, then have no
space between each logical partition, but parted does not support this.
It requires the EBR to be between the previous partition and the next,
so there must be at least one unused sector between them.  I have seen
reports over the years of people running into disks built this way but
never been able to figure out how they got that way.

img6: /dev/sdb6 : start=   158203904, size=     9762816, type=83
Start sector 158203904 out of range.
Failed to add #6 partition: Numerical result out of range

#981692#30
Date:
2021-02-03 21:31:31 UTC
From:
To:
Well at some point in time it did because I remember merging / and /usr
using gparted on a PartedMagic iso Image... Or I did chnage
partitionning after that (windows update for major relaease tend to
corrupt partitions on several of my dual boot PCs...

Well, if you want to change something and thus write sectors why not,
here I cannot even see my partitions.

Using cfdisk probably when there was no such imposed gap beween partitions.

Pfff I have no clue how I could even convert this to something correct now.

#981692#35
Date:
2021-02-21 11:22:19 UTC
From:
To:
So while I admit, the layout was kinda broken, other tools are able to
deal with this layout and even fix it by a simple resize operation
adding the usual 1Mb free space fefore the partition first block.