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

Crash on dlclose when toUtf8 is used in dynamic library

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 4.8.0
    • None
    • Ubuntu 11.10 (running in VM)

    Description

      I have an application that is started as a plugin. The plugin is loaded with dlopen(). Loading, running and closing the plugin is all done in the main() thread. When the loaded library is closed with dlclose(), ~QFactoryLoader generates a SIGSEGV.
      The crash only happens if QString::toUtf8() is used in the dynamic library (does not have to be run, just symbols used).

      Steps to reproduce:

      1. Create a non-qt application (MAIN)
      2. Create a module using QtCore that uses the QString::toUtf8 symbol and starts a QApplication (MODULE).
      3. From MAIN, load MODULE with dlopen().
      4. From MAIN, execute some code in MODULE (via dlsym) that starts a QApplication and quits QApplication (with a QTimer for example).
      5. Unload MODULE with dlclose().
      6. Program segfaults in QFactoryLoader::~QFactoryLoader

      The bug is not present when using 4.7.45 but present in 4.8.0.

      I have attached a code sample that demonstrates this bug. Build and run it with:

      $ tar xzf qtbug.tgz
      $ cd qtbug
      $ make
      Qt BUG related to dlclose
      =========================
      1. Program starting.
      2. Loading dynamic library 'mod.so' linked to Qt.
      3. Getting 'run_test' function.
      4. Passing control to Qt.
      [in mod] Qt lib version: 4.8.0.
      5. 'mod' returned.
      6. Calling dlclose.
      make[3]: *** [CMakeFiles/test] Segmentation fault

      Backtrace

      Program received signal SIGSEGV, Segmentation fault.
      0x00f6ee6e in ?? () from /home/gaspard/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4
      (gdb) bt
      #0 0x00f6ee6e in ?? ()
      from /home/gaspard/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4
      #1 0x00f6b0e2 in QFactoryLoader::~QFactoryLoader() ()
      from /home/gaspard/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4
      #2 0x0050978a in ?? ()
      from /home/gaspard/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so.4
      #3 0x00183d2b in __cxa_finalize () from /lib/i386-linux-gnu/libc.so.6
      #4 0x0042c304 in ?? ()
      from /home/gaspard/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so.4
      #5 0x00bcf850 in _fini ()
      from /home/gaspard/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so.4
      #6 0x00123145 in ?? () from /lib/ld-linux.so.2
      #7 0x00123b98 in ?? () from /lib/ld-linux.so.2
      #8 0x00131cf2 in ?? () from /lib/i386-linux-gnu/libdl.so.2
      #9 0x0011e61f in ?? () from /lib/ld-linux.so.2
      #10 0x0013233a in ?? () from /lib/i386-linux-gnu/libdl.so.2
      #11 0x00131d28 in dlclose () from /lib/i386-linux-gnu/libdl.so.2
      #12 0x080487f8 in main ()

      Attachments

        1. qtbug.tgz
          2 kB
        2. QTBUG-24945.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            gbucher Gaspard Bucher
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes