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

Custom QTextCodecs cause crashes on exit in multi-DLL environments.

    XMLWordPrintable

Details

    Description

      We have a problem with the fact that Qt5 apparently doesn't offer any means to explicitly deregister/delete custom QTextCodecs any more. The problems manifest in the context of DLL unloading where you can run into the situation that the DLL you defined the codecs in gets unloaded, thus the virtual table for your objects points nowhere, then at a later point Qt tries deleting the codecs, which will of course access this no-longer existent virtual table and crash (although the objects themselves are still OK). One instance where this problem definitely manifests is when building ActiveX-DLLs using your idc.exe.

      In Qt4, we avoided this problem cleanly by deleting the codecs when the DLL was unloaded via its atexit-handlers. In Qt5 this seems no longer possible and I can't see any halfway clean workarounds. There should be a way to tell Qt that certain codecs are no longer available, be it via the QTextCodec destructor or an explicit deregistering method.

      The problem of unloading DLLs leaving dangling virtual table pointers should be well documented on the internet. The program where this happens on our side consists of a large number of DLLs and I susped the problem only manifests if the plugin codecs are created in a DLL rather than an EXE, so creating an example program is not practical in this case. The same effect also happens if you create a custom QMimeData object and have it set in the windows clipboard on program termination.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              leonlee Leonard Lee
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes