Results 1 to 9 of 9

Thread: Memory corruption issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Memory corruption issue

    "Running Valgrind" does not fix your code, it's not a magic wand. Valgrind points out problems in your source code which you have to fix yourself.
    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.


  2. The following user says thank you to wysota for this useful post:

    roseicollis (17th February 2015)

  3. #2
    Join Date
    Dec 2014
    Posts
    82
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    10

    Default Re: Memory corruption issue

    Hi wysota, yes I realized that when it crashes this time, but I don't know what do I have to fix exactly.

    Valgrind prints some things like this on the console:

    Qt Code:
    1. ==2848== Invalid write of size 4
    2. ==2848== at 0x435CA6E3: pthread_mutex_init (in /usr/lib/libpthread-2.16.so)
    3. ==2848== by 0x808A450: TLib::CSection::CSection() (Section.cpp:11)
    4. ==2848== by 0x80773D6: CClass1::CClass1() (Class1.cpp:15)
    5. ==2848== by 0x807C642: CClass2::CClass2() (Class2.cpp:21)
    6. ==2848== by 0x807C800: CClass2::Initialize() (Class1.cpp:51)
    7. ==2848== by 0x805A346: BaseWizard::BaseWizard(QWidget*) (basewizard.cpp:49)
    8. ==2848== by 0x80523A2: main (main.cpp:26)
    9. ==2848== Address 0x5b09f14 is 0 bytes after a block of size 292 alloc'd
    10. ==2848== at 0x4008AAD: operator new(unsigned int) (vg_replace_malloc.c:292)
    11. ==2848== by 0x807C638: CClass2::CClass2() (Class2.cpp:21)
    12. ==2848== by 0x807C800: CClass2::Initialize() (Class2.cpp:51)
    13. ==2848== by 0x805A346: BaseWizard::BaseWizard(QWidget*) (basewizard.cpp:49)
    14. ==2848== by 0x80523A2: main (main.cpp:26)
    15.  
    16.  
    17. ==2848== Invalid read of size 4
    18. ==2848== at 0x438EBA44: std::string::_M_mutate(unsigned int, unsigned int, unsigned int) (in /usr/lib/libstdc++.so.6.0.17)
    19. ==2848== by 0x438EBC32: std::string::_M_replace_safe(unsigned int, unsigned int, char const*, unsigned int) (in /usr/lib/libstdc++.so.6.0.17)
    20. ==2848== by 0x438EBCDB: std::string::assign(char const*, unsigned int) (in /usr/lib/libstdc++.so.6.0.17)
    21. ==2848== by 0x438EBF16: std::string::operator=(char const*) (in /usr/lib/libstdc++.so.6.0.17)
    22. ==2848== by 0x80767B4: CClass3::CClass3() (Class3.cpp:39)
    23. ==2848== by 0x807C6E2: CClass2::CClass2() (Class2.cpp:34)
    24. ==2848== by 0x807C800: CClass2::Initialize() (Class2.cpp:51)
    25. ==2848== by 0x805A346: BaseWizard::BaseWizard(QWidget*) (basewizard.cpp:49)
    26. ==2848== by 0x80523A2: main (main.cpp:26)
    27. ==2848== Address 0x5b15efc is 4 bytes after a block of size 48 alloc'd
    28. ==2848== at 0x4008AAD: operator new(unsigned int) (vg_replace_malloc.c:292)
    29. ==2848== by 0x807C6D8: CClass2::CClass2() (Class2.cpp:34)
    30. ==2848== by 0x807C800: CClass2::Initialize() (Class2.cpp:51)
    31. ==2848== by 0x805A346: BaseWizard::BaseWizard(QWidget*) (basewizard.cpp:49)
    32. ==2848== by 0x80523A2: main (main.cpp:26)
    To copy to clipboard, switch view to plain text mode 

    There are like 5 times more that information and then it throws the program. But if I run it without valdring then it says the glibc malloc() memory corruption.

    note: About that references... main and basewizard are my classes on Qt (main.cppp and basewizard is the QWizard), and Class1,2,3 and CSection are from the external libraries

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

    Default Re: Memory corruption issue

    I think the log is pretty much self explanatory. You are accessing memory which you have not allocated. Look at the lines in your code where Valgrind points and see what you do there. Either BaseWizard or CCClass* are not implemented correctly.
    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.


  5. #4
    Join Date
    Dec 2014
    Posts
    82
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    10

    Default Re: Memory corruption issue

    I think the log is pretty much self explanatory. You are accessing memory which you have not allocated. Look at the lines in your code where Valgrind points and see what you do there. Either BaseWizard or CCClass* are not implemented correctly.
    Yes, it is. But I had no idea why so that's why I asked here.. maybe someone had a better idea about my problem and how /where could I find the solution.

    As the last version of the external library works fine, I deduce that the problem is there so I'll let the workmate who made it to fix it.


    Thank you for your help! I'll tell him now all u said that it could be.

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

    Default Re: Memory corruption issue

    Quote Originally Posted by roseicollis View Post
    Yes, it is. But I had no idea why so that's why I asked here.. maybe someone had a better idea about my problem and how /where could I find the solution.
    Not seeing those lines it is hard to guess what's wrong with them

    As the last version of the external library works fine, I deduce that the problem is there so I'll let the workmate who made it to fix it.
    I.... wouldn't be so sure if I were you.
    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.


Similar Threads

  1. Best way to fix a memory corruption issue?
    By agarny in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2012, 07:20
  2. Memory corruption related to signal emission?
    By blooglet in forum Qt Programming
    Replies: 21
    Last Post: 30th December 2011, 19:11
  3. Replies: 2
    Last Post: 7th December 2010, 15:13
  4. memory corruption
    By Rambobino in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2010, 21:35
  5. MDI application memory issue
    By sirQit in forum Qt Programming
    Replies: 7
    Last Post: 8th July 2009, 19:32

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.