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. QMutex - Valgrind - Invalid read of size
Forum Updated to NodeBB v4.3 + New Features

QMutex - Valgrind - Invalid read of size

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

    Hi,
    I had used valgrind for test my program, and i found some "Invalid read of size" in QMutex.unlock() and QMutex.lock() .

    I wrote my own mutex for debug - for example:
    @
    void MyMux::unlock(){
    DEBUG<<"-Unlocking "<<name <<" id:"<< QThread::currentThreadId();
    QMutex::unlock();
    }
    @

    When I locking the mutex Valgrind said:
    Invalid read of size 8 in MyMutex::lock()
    somtime
    Invalid read of size 4 in MyMutex::lock()
    or
    Invalid read of size 1 in MyMutex::lock()

    Whats is wrong?

    [edit: added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      Well usually valgrind throws those type of errors when the memory for an object has been cleaned off the stack.

      It looks like you are using stack variables since you said QMutex.lock() and .unlock() rather than ->lock(), ->unlock().

      My guess is your QMutex is out of scope. If that's the case then you are just getting plain lucky on the memory and mutex working at all. But that is what valgrind is for is to catch problems like that. :)

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      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