Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60678

crash during iteration of QFileInfoList from QDir::entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.6.2, 5.8.0, 5.9.0 Beta 3
    • Core: I/O
    • None
    • Linux

    Description

      See attached example.

      The use case is I'm trying to find all files named "scaling_cur_freq" under /sys/devices/system/cpu, recursively. (I don't trust that different kernel versions won't move them around.) And we do not seem to have decent API for that: we can find directories recursively, but I don't see a good way to find files by name recursively, without writing the recursion myself. (If we did have decent API, then examples/widgets/dialogs/findfiles ought to be changed to use it, because if that were a real application, it would have this feature.) So I did the recursion myself: I call

      dir.entryInfoList(nameFilters, QDir::NoDotAndDotDot | QDir::AllDirs);
      

      then iterate the results, and if any result is another directory, recurse. But I crash during that loop, in the QFileInfo copy constructor of all places. The depth of recursion is only 3... it's not stack overflow.

      1 std::__atomic_base<int>::operator++                      atomic_base.h   296 0x7ffff77c270b 
      2 QAtomicOps<int>::ref<int>                                qatomic_cxx11.h 265 0x7ffff77c1b54 
      3 QBasicAtomicInteger<int>::ref                            qbasicatomic.h  113 0x7ffff77c0e5c 
      4 QSharedDataPointer<QFileInfoPrivate>::QSharedDataPointer qshareddata.h   92  0x7ffff7959599 
      5 QFileInfo::QFileInfo                                     qfileinfo.cpp   375 0x7ffff79561fb 
      6 find                                                     main.cpp        10  0x4016dc       
      7 find                                                     main.cpp        13  0x40185c       
      8 find                                                     main.cpp        13  0x40185c       
      9 main                                                     main.cpp        23  0x401aef       
      

      The code isn't quite right, but I still was surprised to get a crash.

      Attachments

        1. alldirs.pro
          0.7 kB
          Shawn Rutledge
        2. main.cpp
          0.8 kB
          Shawn Rutledge
        3. working.cpp
          0.9 kB
          Shawn Rutledge
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            srutledg Shawn Rutledge
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes