Results 1 to 20 of 22

Thread: Memory corruption related to signal emission?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Memory corruption related to signal emission?

    I'd rather not post the entire program online
    I understand.
    Does it crash if you do not startReceiver() ? You said that there are threads involved - to me its always first place to look for potential errors.
    //edit: ok, probably there you have the "emit" statements. You may try to implement single-threaded version of the receiver, my bet is that threads are somehow responsible for the app crash.

  2. #2
    Join Date
    Nov 2010
    Posts
    77
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17

    Default Re: Memory corruption related to signal emission?

    It does not crash if I don't call startReceiver(). But like I said here: if I remove these two signal emission commands (they're executed on the receiver thread, by the way) and still call startReceiver(), the program doesn't crash either. Even when no slots are connected to these signals, the mere emission of these signals causes a SIGSEGV somewhere else in the program. This leads me to believe it's not a thread safety issue but a memory corruption issue. I build with Qt 4.7.4, but any time I suspect an error is my code is caused by a Qt-related bug it turns out I'm wrong.

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Memory corruption related to signal emission?

    I think its not possible to help you more without digging through the sources.
    Its all up to your creative thinking now. You may try to create separate application, where you can test the VideoStream and VideoStreamerSession classes, without the gui layer. Or try to implement single-threaded version of receiver. Or try to allocate the _vss on heap (if you are out of ideas, why not try this).
    Sorry, but without seeing the code, I can't help you more.

  4. #4
    Join Date
    Nov 2010
    Posts
    77
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17

    Default Re: Memory corruption related to signal emission?

    Holy smokes... I just did some more digging and I found the culprit. I looked through all the "// TODO" comments in my code and then I remembered I had an odd issue with a signal/slot connection on a QTimer* that produced a warning in the debug output. The timer just wouldn't fire. I commented out the connect() command because I had more important things to do. When I came back to this snippet of code, I noticed that I hadn't initialized the QTimer*... I feel like crap for wasting your and my own time. Too bad Valgrind didn't detect this, because then the error would have been exposed much earlier.

    Thanks for your help, though!

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

    Default Re: Memory corruption related to signal emission?

    that uninited pointer isnt around or as a consequence of launchGui, is it? your valgrind output says ''uninit'd value was created by a stack allocation'' main.cpp:30
    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.

  6. #6
    Join Date
    Nov 2010
    Posts
    77
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17

    Default Re: Memory corruption related to signal emission?

    I've posted main.cpp here. I have no idea what Valgrind is referring to. Probably char* ip but since argv[1] isn't deallocated until the program stops I don't see a problem here.

Similar Threads

  1. Replies: 2
    Last Post: 7th December 2010, 16:13
  2. memory corruption
    By Rambobino in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2010, 22:35
  3. Replies: 3
    Last Post: 19th January 2010, 21:26
  4. Workload to the Application:Related to Signal and Slot
    By soumyadeep_pan in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2009, 12:08
  5. Replies: 3
    Last Post: 11th January 2008, 18:34

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.