Oh, of course it was in my cleanup which I did not show. It had nothing to do 
with reading multiple images in a row, it was just when I closed one. Here's 
the destructor as I had it when the error happened:
~Disk() {
if (disk) {
ped_disk_destroy(disk);
disk = nullptr;
}
if (dev) {
ped_device_close(dev);
ped_device_destroy(dev);
dev = nullptr; }
}

here's me fix:

~Disk() {
if (disk) {
ped_disk_destroy(disk);
disk = nullptr;
}
if (dev) {
if (dev->open_count > 0) ped_device_close(dev);
dev = nullptr;
} }

note that if I call ped_device_destroy(dev) before dev = nullptr it gives me a
free(): double free detected in tcache 2
error.
On Wednesday, March 11th, 2026 at 3:11 AM, [email protected] <[email protected]> wrote:

> Occurred after reading partitions off an .img file with a fat16 partition, 
> immediately after reading the partitions of a an .img file with two ntfs, and 
> ext4, and a linux-swap partition.
> 14: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x50) [0x7f797e786cb0] 
> 13: /lib/x86_64-linux-gnu/libparted.so.2(ped_device_close+0x69) 
> [0x7f797e7871e9] 12: read-img(+0x824e) [0x55b9f4fa024e] 11: read-img(+0x81f5) 
> [0x55b9f4fa01f5] 10: read-img(+0x81d5) [0x55b9f4fa01d5] 9: read-img(+0x81a3) 
> [0x55b9f4fa01a3] 8: read-img(+0x7b9d) [0x55b9f4f9fb9d] 7: read-img(+0x7824) 
> [0x55b9f4f9f824] 6: read-img(+0x38a5) [0x55b9f4f9b8a5] 5: read-img(+0x3546) 
> [0x55b9f4f9b546] 4: read-img(+0x3357) [0x55b9f4f9b357] 3: 
> /lib/x86_64-linux-gnu/libc.so.6(+0x29ca8) [0x7f797e207ca8] 2: 
> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x7f797e207d65] 1: 
> read-img(+0x3221) [0x55b9f4f9b221] A bug has been detected in GNU Parted. 
> Refer to the web site of parted 
> http://www.gnu.org/software/parted/parted.html for more information of what 
> could be useful for bug submitting! Please email a bug report to 
> [email protected] containing at least the version (3.6) and the following 
> message: Assertion (dev->open_count > 0) at ../../libparted/device.c:254 in 
> function ped_device_close() failed. Aborted
>
> Here's the relevant code block which was run twice in succession (without 
> closing in between):
> dev = pec_device_get(imgpath.c_str());
> if (!dev) {
> return;
> }
> if (!ped_device_open(dev)) {
> ped_device_destroy(dev);
> return;
> }
> disk = ped_disk_new(dev);
> if (!disk) {
> ped_device_close(dev);
> ped_device_destroy(dev);
> return;
> }
> PedPartition *part = nullptr;
> while ((part = ped_disk_next_partition(disk, part)) != nullptr) {
> parts.emplace_back(*part);
> ...
  • bug#80586... seth--- via Bug reports for the GNU Parted disk partition editor
    • bug#... seth--- via Bug reports for the GNU Parted disk partition editor

Reply via email to