[gparted] Prevent assert failure from OperationCheck::get_partition_new() (#767233)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Prevent assert failure from OperationCheck::get_partition_new() (#767233)
- Date: Sun, 5 Jun 2016 19:26:25 +0000 (UTC)
commit 1f2a50544d6b0926e1f02f7eb24cf8503bcc1a02
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat Jun 4 09:26:22 2016 +0100
Prevent assert failure from OperationCheck::get_partition_new() (#767233)
Composing these operations caused GParted to abort on an assert failure:
(1) Check an existing partition,
(2) Create a new partition,
(3) Delete new partition.
# ./gpartedbin
======================
libparted : 2.4
======================
**
ERROR:OperationCheck.cc:40:virtual GParted::Partition& GParted::OperationCheck::get_partition_new():
assertion failed: (false)
Aborted (core dumped)
# gdb ./gpartedbin core.8876 --batch --quiet --ex backtrace -ex quit
[New Thread 8876]
[New Thread 8879]
[Thread debugging using libthread_db enabled]
Core was generated by `./gpartedbin'.
Program terminated with signal 6, Aborted.
#0 0x000000361f2325e5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
#0 0x000000361f2325e5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x000000361f233dc5 in abort () at abort.c:92
#2 0x0000003620a67324 in g_assertion_message (domain=<value optimized out>, file=<value optimized
out>, line=<value optimized out>, func=0x50f400 "virtual GParted::Partition&
GParted::OperationCheck::get_partition_new()", message=0x1d37a00 "assertion failed: (false)") at
gtestutils.c:1358
#3 0x0000003620a678f0 in g_assertion_message_expr (domain=0x0, file=0x50f1a8 "OperationCheck.cc",
line=40, func=0x50f400 "virtual GParted::Partition& GParted::OperationCheck::get_partition_new()",
expr=<value optimized out>) at gtestutils.c:1369
#4 0x0000000000498e21 in GParted::OperationCheck::get_partition_new (this=0x1d1bb30) at
OperationCheck.cc:40
#5 0x00000000004c66ec in GParted::Win_GParted::activate_delete (this=0x7fff031c3e30) at
Win_GParted.cc:2068
...
When Win_GParted::activate_delete() was stepping through the operation
list removing operations (2 & 3 in the above recreation steps) which
related to the new partition never to be created it called
get_partition_new() on all operations in the list. This included
calling get_partition_new() on the check operation (1 in the above
recreation steps). As partition_new was not set or used by the check
operation get_partition_new() asserted false and crashed GParted.
Fix by populating the partition_new member in OperationCheck objects,
thus allowing get_partition_new() to be called on the object. As a
check operation doesn't change any partition boundaries or file system
attributes, just duplicate the new partition from the original
partition.
Bug 767233 - GParted core dump on assert failure in
OperationDelete::get_partition_new()
include/OperationCheck.h | 3 ---
src/OperationCheck.cc | 19 +++----------------
src/Win_GParted.cc | 3 +++
3 files changed, 6 insertions(+), 19 deletions(-)
---
diff --git a/include/OperationCheck.h b/include/OperationCheck.h
index a060201..336d2ea 100644
--- a/include/OperationCheck.h
+++ b/include/OperationCheck.h
@@ -36,9 +36,6 @@ private:
OperationCheck( const OperationCheck & src ); // Not implemented copy constructor
OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator
- Partition & get_partition_new();
- const Partition & get_partition_new() const;
-
void create_description() ;
bool merge_operations( const Operation & candidate );
} ;
diff --git a/src/OperationCheck.cc b/src/OperationCheck.cc
index 666d646..918853d 100644
--- a/src/OperationCheck.cc
+++ b/src/OperationCheck.cc
@@ -27,28 +27,15 @@ OperationCheck::OperationCheck( const Device & device, const Partition & partiti
this->device = device.get_copy_without_partitions();
this->partition_original = partition.clone();
+ this->partition_new = partition.clone();
}
OperationCheck::~OperationCheck()
{
delete partition_original;
+ delete partition_new;
partition_original = NULL;
-}
-
-Partition & OperationCheck::get_partition_new()
-{
- g_assert( false ); // Bug: OperationCheck class doesn't use partition_new
-
- // Not reached. Return value to keep compiler quiet.
- return *partition_new;
-}
-
-const Partition & OperationCheck::get_partition_new() const
-{
- g_assert( false ); // Bug: OperationCheck class doesn't use partition_new
-
- // Not reached. Return value to keep compiler quiet.
- return *partition_new;
+ partition_new = NULL;
}
void OperationCheck::apply_to_visual( PartitionVector & partitions )
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 9e66b41..27bd45b 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -2640,6 +2640,9 @@ void Win_GParted::activate_check()
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid
display partition object
+ // FIXME: Consider constructing new partition object with zero unallocated and
+ // messages cleared to represent how applying a check operation also grows the
+ // file system to fill the partition.
Operation * operation = new OperationCheck( devices[current_device], *selected_partition_ptr );
operation ->icon = render_icon( Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]