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. Strange debugger behaviour

Strange debugger behaviour

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k 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.
  • M Offline
    M Offline
    mvidelgauz
    wrote on last edited by
    #1

    Hello all!

    When I am running my program without debugger it works as expected. But when I try to set breakpoints and step over them with debugger (Qt Creator 2.7.2) the following happens. Here is piece of code:
    @ QList<QVariant> fieldList(record.fieldList);
    if (column < fieldList.size())
    {
    ......
    }
    return QVariant();
    @

    When I stop at line 2 I can see that "fieldList" contains 6 items, as expected. "column" is 0. Than I am trying to step over line 2 and getting to line 6
    Q1: why if column==0 and fieldList.size() is 6?

    Also, debugger tells me that "fieldList" is now <not accessible>
    Q2: Was it already destroyed because optimizer decided it is not needed when I am at line 6?

    Than I am hitting "Continue (F5)" button. Boom!
    The inferior stopped because it received a signal from the Operating System.
    Signal name: SIGSEGV
    Signal meaning: Segmentation fault.

    Call stack shows fault at line 3 of ("qgenericatomiv.h"):
    @
    T load(const T &_q_value) Q_DECL_NOTHROW
    {
    return _q_value;
    }
    @

    called from (qbasicatomic.h)
    @
    T load() const Q_DECL_NOTHROW { return Ops::load(_q_value); }
    @

    called from line 2 of ("qrefcount.h"):
    @
    inline bool deref() Q_DECL_NOTHROW {
    int count = atomic.load();
    if (count == 0) // !isSharable
    return false;
    if (count == -1) // isStatic
    return true;
    return atomic.deref();
    }
    @

    called from line 4 of ("qlist.h")
    @
    template <typename T>
    Q_OUTOFLINE_TEMPLATE QList<T>::~QList()
    {
    if (!d->ref.deref())
    dealloc(d);
    }
    @

    called from line 6 of my code.
    Ok, I understand abut leaving scope and thus destroying "fieldList". I also know I could use
    @
    const QList<QVariant>& fieldList = record.fieldList;
    @
    and actually I had that before but QList documentation says that copy-constructor creates QList that "is implicitly shared. This makes returning a QList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time." And I know I am not modifying "fieldList"

    I had different variations of this code with different appearances of this problem but actually it is all the same three points:

    1. "fieldList" becomes <not accessible>
    2. 0 is not considered valid index in "fieldList"
    3. segmentation fault at the end

    Again, without debugger everything is working as expected. No crashes and correct content in QTreeView. But I sometimes need to step over code to watch something...

    Any ideas will be appreciated!

    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