[gparted] Avoid crash reading JFS usage on Fedora 30 (!49)(#794947)



commit 7a7d0a2119290bb50ec1977fb5d3b8edadd55a58
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Oct 27 14:23:51 2019 +0000

    Avoid crash reading JFS usage on Fedora 30 (!49)(#794947)
    
    Running JFS read usage test on Fedora 30 fails like this:
    
        $ ./test_SupportedFileSystems --gtest_filter='*ReadUsage/jfs'
    ...
        [ RUN      ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs
        unknown file: Failure
        C++ exception with description "std::bad_alloc" thrown in the test body.
        [  FAILED  ] My/SupportedFileSystemsTest.CreateAndReadUsage/jfs, where GetParam() = 17 (41833 ms)
    
    However the same test passes on Fedora 29, Fedora 31 Beta, CentOS 7,
    Debian 10 and Ubuntu 18.04 LTS.
    
    Also running GParted on Fedora 30 crashes just the same when reading JFS
    usage:
    
        # gparted
        GParted 1.0.0
        configuration --enable-libparted-dmraid --enable-online-resize
        libparted 3.2
        terminate called after throwing an instance of 'std::bad_alloc'
          what():  std::bad_alloc
        /usr/bin/gparted: line 202: 19218 Aborted                 (core dumped) $BASE_CMD
    
    Running jfs_debugfs to query the file system usage the same way GParted
    does produces an infinite amount of repeating output:
    
        # echo dm | jfs_debugfs /dev/sdb1
    
    So jfs_debugfs gets stuck in an infinite loop inside the dmap subcommand
    when it encounters EOF.  GParted and the read JFS usage test read this
    output until memory is exhausted and crash.  This is exactly what was
    happening in closed bug 794947.  Even installed jfsutils from Fedora 29
    on Fedora 30 and visa versa.  jfs_debugfs still produced an infinite
    amount of output on Fedora 30 and worked correctly on Fedora 29.  So
    it's not the build of jfsutils, but something in the OS that is making
    the difference!
    
    Anyway fix by providing the instruction to exit from the dmap
    subcommand, and quit from jfs_debugfs itself, like this:
    
        # echo -e 'dmap\nx\nquit' | jfs_debugfs /dev/sdb1
    
    Bug 794947 - gparted hangs when sees JFS partition on discovering
                 partitions
    Closes !49 - Add file system interface tests

 src/jfs.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/jfs.cc b/src/jfs.cc
index 720eb877..64643d87 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -81,7 +81,7 @@ FS jfs::get_filesystem_support()
 void jfs::set_used_sectors( Partition & partition ) 
 {
        const Glib::ustring jfs_debug_cmd = "jfs_debugfs " + Glib::shell_quote( partition.get_path() );
-       if ( ! Utils::execute_command( jfs_debug_cmd, "dm\n", output, error, true ) )
+       if (! Utils::execute_command(jfs_debug_cmd, "dmap\nx\nquit\n", output, error, true))
        {
                //blocksize
                Glib::ustring::size_type index = output.find( "Block Size:" );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]