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. Crash in QString destructor (while fetching reference count).
Forum Updated to NodeBB v4.3 + New Features

Crash in QString destructor (while fetching reference count).

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.2k 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.
  • B Offline
    B Offline
    Bart_Vandewoestyne
    wrote on last edited by Bart_Vandewoestyne
    #1

    I have a class Bar with a member variable of type QString. When the destructor of this class is called, I get a crash with the error message:

    Exception thrown: read access violation.
    
    _q_value was 0x58A0620.
    
    If there is a handler for this exception, the program may be safely continued.
    

    The top of the call stack looks as follows:

    Qt5Cored.dll!QGenericAtomicOps<QAtomicOpsBySize<4> >::load<int>(const int & _q_value) Line 90   C++
    Qt5Cored.dll!QBasicAtomicInteger<int>::load() Line 103  C++
    Qt5Cored.dll!QtPrivate::RefCount::deref() Line 66       C++
    Qt5Cored.dll!QString::~QString() Line 1135      C++
    Foo.dll!Bar::~Bar()     C++
    ... irrelevant stuff ...
    

    So I think what happens is the following:

    • QString destructor is called, so the reference count to the shared data must be decreased by one.
    • To decrease the reference count, the current reference count value is loaded (atomically).
    • Loading the current reference count (_q_value) fails.

    I have no idea why this happens and am looking for suggestions for what I could possibly doing wrong in my code (certain anti-patterns related to QString and implicit data sharing???)

    Any hint on what to look for in order to diagnose and fix this problem is very welcome. I cannot share any code due to company restrictions. Qt version we are using is our own build of Qt 5.12.2.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I would guess you're deleting your class 'Bar' twice but it's only a guess without a reproducible minimal example.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4

      • Login

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