Results 1 to 5 of 5

Thread: Strange qsrand error when debugging with totalview/memoryscape

  1. #1
    Join Date
    Apr 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Strange qsrand error when debugging with totalview/memoryscape

    I hope there is someone using TotalView/MemoryScape here.

    I use this tool for about 5 years now (from before the time they split it into two products). I mainly used for memory leak detection - IMO about 1000x better than gdb, click, catch. It was it until now (while I debugged only STL based stuff). Now I have it running on CentOS 6 32bit.

    The application I originally tried to debug is a complex multithreaded beast (I have about 200 bytes leak per thread and that adds up to lots of bytes finally). To my surprise, it fails at the first step with the qsrand call.

    It says: "Error: Allocator returned a misaligned block: heap may be corrupted".

    No matter what I do, the application does not continue. I hope there is someone out there using TotalView who can tell me what is going on since rougewave support does not give a hand with qt.

    Alternatively, I would welcome any tool what does the same memleak detection as TV does (valgrind output is a nightmare, something nice is needed what is capable to output results in an easily comprehensible format after creating and destroying 100000 threads or so).

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange qsrand error when debugging with totalview/memoryscape

    not really a Qt programming question, is it?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Strange qsrand error when debugging with totalview/memoryscape

    Quote Originally Posted by amleto View Post
    not really a Qt programming question, is it?
    Moved to General Programming.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Dec 2012
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Strange qsrand error when debugging with totalview/memoryscape

    Greetings Sandor,

    I'm the product manager for TotalView and MemoryScape. Google brought this post to my attention.

    Just a clarifying nit. We do now sell MemoryScape separately, but we also include it in the vast majority of configurations of TotalView -- so most people who have TotalView are able to use MemoryScape in the way you are describing, even with the latest versions.

    First, did you try asking your question to our support folks or on the rouge wave forum? I don't see it in either system?

    In any case I can probably help you with your issue.

    What TotalView/MemoryScape is telling you with that message is that a malloc or realloc call returned a non-aligned address which is usually a bad sign. I'd focus my diagnostic efforts in two areas:

    1. see if you can pin down exactly what call that might have been and double check that you are seeing that non-aligned return value.

    2. see if you can figure out under what conditions this is happening.

    A couple of things you should look at.

    1. The stack backtrace. This diagnostic would generally be returned and the target stopped in the process of an alloc() or malloc() call. Do you see this on the backtrace?

    2. Is this the first allocation in the program or the 99999th? You might be able to tell this by looking at the heap map (if there are already allocations there this this isn't the first) or by putting a breakpoint around malloc (or realloc, or whichever call you are using).

    3. Does this happen with a really simple program. Make a test rig program that calls qsrand(). Does it work?

    You mention that your program is multi-threaded. This kind of heap corruption often indicates that one of the threads is writing into part of the memory where it should not be writing. Some possible causes:

    A. Writing past the end of an array
    B. A race condition occurs and the program gets confused and starts doing crazy things
    C. A pointer is shared between threads and copied around. Thread A determines that it is done with the object and calls free() (or deletes the object). Thread B still has a copy of the pointer and tries to access it. *Blam* bad data gets written over libc's own data structures.
    D. A "plain old" wild pointer. This can happen when you read/write uninitialized data.

    4. Can you tell your multi-threaded program to run single threaded (for testing purposes)? If so does this problem go away?

    Let me know if this helps.

    Cheers,
    Chris

  5. #5
    Join Date
    Dec 2012
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Strange qsrand error when debugging with totalview/memoryscape

    Sandor,

    Another thought, from one of my colleagues here:

    "You can go into the advanced options and turn off the reporting of that particular
    error. Sometimes they are real, but don't affect the running of the program.
    That might get him past the beginning and allow him to get to the problem with
    his leaks."

    Cheers,
    Chris

Similar Threads

  1. SIGSEGV Error when debugging with Qt creator.
    By jiapei100 in forum Qt Programming
    Replies: 5
    Last Post: 22nd July 2012, 12:19
  2. Debugging error of a simple program
    By Professor widget in forum Newbie
    Replies: 5
    Last Post: 11th February 2011, 23:24
  3. Error when debugging with Qt creator
    By NewLegend in forum Qt Programming
    Replies: 3
    Last Post: 12th August 2010, 19:28
  4. Replies: 2
    Last Post: 11th August 2010, 10:13
  5. Problem with qsrand and time(0)[SOLVED]
    By jano_alex_es in forum Newbie
    Replies: 2
    Last Post: 17th July 2009, 08:41

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.