Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Could this be a possible bug for Qt's SQL database?
Forum Updated to NodeBB v4.3 + New Features

Could this be a possible bug for Qt's SQL database?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 807 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nyaruko
    wrote on last edited by
    #1

    I have met a problem stated in this question: http://qt-project.org/forums/viewthread/49138/
    After I have done some research and asked some of my friends. I found that the default constructor of
    QSqlDatabase might be the problem.

    Here is the thing:
    The default constructor of QSqlDatabase used a shared_null.
    Note that the shared_null is an object indicating an invalid database, not a plain null pointer.

    Here is the code: http://code.woboq.org/qt5/qtbase/src/sql/kernel/qsqldatabase.cpp.html#_ZN19QSqlDatabasePrivate11shared_nullEv

    You can see these are static variables in the function, and -- static variable initialization is not thread-safe!

    See:
    http://blogs.msdn.com/b/oldnewthing/archive/2004/03/08/85901.aspx
    http://www.codeguru.com/cpp/misc/misc/assemblylanguage/article.php/c12897/Function-Static-Variables-in-MultiThreaded-Environments.htm

    So, if you call these default constructors in different threads, there might be problems, in my case, my suspicion is that the shared_null is initialized twice due to this kind of race condition. As a result, the ref counting went wrong and the delete is called on this static object (which should not be delete-able).

    I am new to Qt, any one have great ideas about this?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      That question would be more suited for the interest mailing list. You'll find there Qt's developers/maintainers (this forum is more user oriented)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved