Results 1 to 4 of 4

Thread: Write access violation while attaching QwtPlotCurve?

  1. #1
    Join Date
    Sep 2015
    Posts
    36
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Write access violation while attaching QwtPlotCurve?

    Today I encountered access violation bug, that I can't fix by any means.

    First of all - our program is using Qt plugin system. Part using Qwt is a plugin that will allow user to plot insides of dataset. And everything works fine and stable - unless we want to reload plugins. What it actually means - we just delete everything created by all plugins and create it from scratch again, just like it was the first time when program starts. So in this case my class using Qwt (inheriting QwtPlot) is destroyed, everything in it is destroyed, and then everything else somehow involved is destroyed. When we are done cleaning plot plugin is created again.

    And algorithm causing this looks like that:

    1. We start program, load dataset and plot one or more curves:

    bug7.jpg

    If we don't plot anything (no QwtPlotCurve was attached to plot) - bug will not appear. Plugin will be entirely destroyed, reloaded and it will work fine.

    2. We reload plugin (destroy it entirely and make new identical one).

    3. When we want to attach curve to the plot, so we can see it - write access violation appears.

    We suppose that it may somehow involve Qwt itself (item attaching to be precise), because we are nearly sure that everything is deleted properly.

    It looks like everything starts here:


    QwtPlotWithFunctions is a class inheriting QwtPlot. In drawSignal we go past setSamples, so data given to curve is most probably (well, it always was) correct. When we reach attachment - this is for sure the place where everything starts to fall apart. We tested push_back marked by arrow and we are sure that program crashes on attachment. curves is a QVector containing pointers to QwtPlotCurves - they are created in memory when we load dataset, so there are as many curves as there are signals possible to plot.

    Then debugger lead us further:







    And it looks like everything ends up when qVariantSetValue is called. I uploaded only last 3 things debugger shows, because of limit of 4 images per post. I may upload the rest if you wish.

    What may cause this kind of bug and where should we look for solution?
    Last edited by Khaine; 20th April 2016 at 19:40.

  2. #2
    Join Date
    Sep 2015
    Posts
    1
    Thanks
    1

    Default Re: Write access violation while attaching QwtPlotCurve?

    Hi everyone, I work on this project with Khaine and wanted to clarify our problem a bit.
    To add more about the plugin reloading part - we destroy the plugin using QPluginLoader::unload() and delete loader object afterwards. We are aware of an issue described in this topic on SO which causes difficult to debug crashes when trying to access objects left undeleted by unmounted plugin, Windows OS (experienced it with our other plugins) - I mention it as it might be the case, but do not think it actually happens now.

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Write access violation while attaching QwtPlotCurve?

    Quote Originally Posted by Khaine View Post
    And it looks like everything ends up when qVariantSetValue is called.
    What may cause this kind of bug and where should we look for solution?
    The crash happens while wrapping a QwtText into a QVariant - both temporary objects on the stack, that should be unrelated to loading/unloading plugins. So I would indeed have a deeper look at the code of qVariantSetValue and maybe the Q_DECLARE_METATYPE(QwtText) macro.

    Beside that be aware of QwtText::textEngine(). The text engines are created when being used first and will never be destroyed.

    Uwe

  4. The following 2 users say thank you to Uwe for this useful post:

    Aningan (21st April 2016), Khaine (21st April 2016)

  5. #4
    Join Date
    Sep 2015
    Posts
    36
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Write access violation while attaching QwtPlotCurve?

    EDIT:

    http://stackoverflow.com/questions/2...namic-plug-ins

    Thanks Uwe, we did some research on Q_DECLARE_METATYPE. It looks like unloading plugins is not even supported in Qt5, so we have to disable this feature anyway which will make problem not-existant. It looks like this problem was most likely related to unloading plugins. It looks like declaring class in QtMetaType system that was declared in already unmounted .dll causes QVariant to not work properly. In our case QwtText has type 1044 and it's probably declared second time after reload.
    Last edited by Khaine; 21st April 2016 at 12:45.

Similar Threads

  1. Access Violation with signal emit
    By antz24 in forum Newbie
    Replies: 1
    Last Post: 26th September 2014, 12:01
  2. Replies: 1
    Last Post: 8th January 2014, 09:15
  3. Access violation using QTableWidget
    By mchome in forum Newbie
    Replies: 2
    Last Post: 4th September 2012, 08:39
  4. Access violation -- qobject.cpp
    By willief in forum Newbie
    Replies: 9
    Last Post: 14th February 2011, 23:55
  5. Access Violation with VS2008
    By Takatschio in forum Qt Programming
    Replies: 3
    Last Post: 19th August 2010, 10:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.