Subject: bug#32666: Assertion (metadata_length > 0) failed

From: Kevin Locke <[email-masked]>
Date: Mon, 24 Sep 2018 20:46:39 -0600

On Sat, 2018-09-08 at 21:28 +0100, Nikolaus Rath wrote:
> On my system, parted crashes with:
>
> [...]
>
> Assertion (metadata_length > 0) at ../../../libparted/labels/dos.c:2313 in function
> add_logical_part_metadata() failed.
> 
> Aborted                                                                   

I encountered the same assertion failure from the resizepart command.
I was able to get a full backtrace after building from current master
(f0cfa958) with CFLAGS="-g -O0" as a result of running the command:

parted /dev/sdb resizepart 5 976824319s

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff7b3f2f1 in __GI_abort () at abort.c:79
#2  0x00007ffff7f7c80b in ped_assert (
    cond_text=0x7ffff7fb75bc "metadata_length > 0", 
    file=0x7ffff7fb7191 "dos.c", line=2305, 
    function=0x7ffff7fb7930 <__PRETTY_FUNCTION__.5302> "add_logical_part_metadata") at debug.c:111
#3  0x00007ffff7f9ad96 in add_logical_part_metadata (disk=0x55555559b210, 
    log_part=0x5555555a1f80) at dos.c:2305
#4  0x00007ffff7f9b13b in msdos_alloc_metadata (disk=0x55555559b210)
    at dos.c:2436
#5  0x00007ffff7f8135f in _disk_alloc_metadata (disk=0x55555559b210)
    at disk.c:1010
#6  0x00007ffff7f81782 in _disk_pop_update_mode (disk=0x55555559b210)
    at disk.c:1163
#7  0x00007ffff7f83968 in ped_disk_set_partition_geom (disk=0x55555559b210, 
    part=0x5555555a1eb0, constraint=0x5555555949d0, start=976562176, 
    end=976824319) at disk.c:2171
#8  0x000055555555da09 in do_resizepart (dev=0x7fffffffe4c0, 
    diskp=0x7fffffffe4b8) at parted.c:1576
#9  0x0000555555559f09 in command_run (cmd=0x555555574b40, dev=0x7fffffffe4c0, 
    diskp=0x7fffffffe4b8) at command.c:141
#10 0x00005555555638f6 in interactive_mode (dev=0x7fffffffe4c0, 
    disk=0x7fffffffe4b8, cmd_list=0x55555556b6c0 <commands>) at ui.c:1630
#11 0x000055555555fae2 in main (argc=0, argv=0x7fffffffe5c8) at parted.c:2356

The output of `parted /dev/sdb unit co print unit s print`:

Model: ATA Samsung SSD 860 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size   Type      File system  Flags
 1      1049kB  269MB   268MB  primary
 2      269MB   404MB   134MB  primary
 3      404MB   500GB   500GB  primary
 4      500GB   1000GB  500GB  extended               lba
 5      500GB   500GB   134MB  logical
 6      500GB   996GB   496GB  logical

Model: ATA Samsung SSD 860 (scsi)
Disk /dev/sdb: 1953525168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start       End          Size        Type      File system  Flags
 1      2048s       526335s      524288s     primary
 2      526336s     788479s      262144s     primary
 3      788480s     976562174s   975773695s  primary
 4      976562175s  1953525167s  976962993s  extended               lba
 5      976562176s  976824318s   262143s     logical
 6      976824320s  1945136559s  968312240s  logical

Let me know if there is any other information I can provide.

Thanks,
Kevin