Testing on RHEL6.2, I found that When running tests/t9050-partition-table-types.sh with a simulated sector size of 1024, we'd get a failed assertion in mac.c. This is done as part of a top-level "make check", but so far, this failure has shown up only on RHEL-6.2.
Program received signal SIGABRT, Aborted. 0x0000003e35632885 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); Missing separate debuginfos, use: debuginfo-install libgcc-4.4.6-3.el6.x86_64 libudev-147-2.40.el6.x86_64 (gdb) bt #0 0x0000003e35632885 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x0000003e35634065 in abort () at abort.c:92 #2 0x00007ffff7db1bd8 in ped_assert ( cond_text=0x7ffff7de9e40 "i <= disk->dev->sector_size / 512", file=0x7ffff7de9b01 "mac.c", line=707, function=0x7ffff7dea310 "_disk_analyse_ghost_size") at debug.c:111 #3 0x00007ffff7dd396b in _disk_analyse_ghost_size (disk=0x619a70) at mac.c:707 #4 0x00007ffff7dd3a84 in mac_read (disk=0x619a70) at mac.c:749 #5 0x00007ffff7db524d in ped_disk_new (dev=0x61aa40) at disk.c:199 #6 0x0000000000404b47 in do_mklabel (dev=0x7fffffffe2c0) at parted.c:493 #7 0x0000000000404029 in command_run (cmd=0x614c10, dev=0x7fffffffe2c0) at command.c:139 #8 0x000000000040cd4e in non_interactive_mode (dev=0x7fffffffe2c0, cmd_list=0x6121e0, argc=2, argv=0x7fffffffe3d0) at ui.c:1640 #9 0x0000000000408fac in main (argc=2, argv=0x7fffffffe3d0) at parted.c:2172 690 static int 691 _disk_analyse_ghost_size (PedDisk* disk) 692 { 693 MacDiskData* mac_disk_data = disk->disk_specific; 694 695 void *buf = ped_malloc (disk->dev->sector_size); 696 if (!buf) 697 return 0; 698 699 int i; 700 int found = 0; 701 for (i = 1; i < 64; i *= 2) { 702 if (!ped_device_read (disk->dev, buf, i, 1)) 703 break; 704 if (_rawpart_check_signature (buf) 705 && !_rawpart_is_void (buf)) { 706 mac_disk_data->ghost_size = i; >707 PED_ASSERT (i <= disk->dev->sector_size / >512); 708 found = 1; 709 break; 710 } 711 } 712 free (buf); (gdb) p i $1 = 4 (gdb) p disk->dev->sector_size $2 = 1024 Here's the fix: >From 4559c510f02a691d90329fd646e8eefe2e73e6d2 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Sun, 26 Feb 2012 18:04:37 +0100 Subject: [PATCH] libparted: avoid unwarranted failed assertion during mklabel This could happen when running "parted -s $dev mklabel $type" for nearly any $type, assuming the underlying disk's sector size is larger than 512 bytes. This particular failure was noticed by running tests/t9050-partition-table-types.sh with a simulated sector size of 1024, as is done as part of a top-level "make check", but so far, this failure has shown up only on RHEL-6.2. That test attempts to exercise an ugly part of partition table creation: during creation, parted checks for an existing partition table by iterating through its list of known types and attempting to read the disk, looking for a preexisting table. Knowing this, the test takes all pairs of partition table types, <A,B> and first creates a type of type A, and then creates on top of that (erasing the original) a table of type B. * libparted/labels/mac.c (_disk_analyse_ghost_size): Remove bogus assertion. If the number of the sector with a matching signature is too large, simply reject it by returning 0. * NEWS (Bug fixes): Mention this. --- NEWS | 3 +++ libparted/labels/mac.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index fc93e98..50d9126 100644 --- a/NEWS +++ b/NEWS @@ -71,6 +71,9 @@ GNU parted NEWS -*- outline -*- of partitions the device can hold. With this change, parted now correctly informs kernel about new partitions on partitionable MD RAID devices. + libparted: creating a new partition table on a device with an existing + mac partition table could result in a failed assertion. + ** Changes in behavior Floppy drives are no longer scanned on linux: they cannot be partitioned diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c index 41ea398..1f59a1a 100644 --- a/libparted/labels/mac.c +++ b/libparted/labels/mac.c @@ -704,8 +704,7 @@ _disk_analyse_ghost_size (PedDisk* disk) if (_rawpart_check_signature (buf) && !_rawpart_is_void (buf)) { mac_disk_data->ghost_size = i; - PED_ASSERT (i <= disk->dev->sector_size / 512); - found = 1; + found = (i <= disk->dev->sector_size / 512); break; } } -- 1.7.9.2.263.g9be8b7