Results 1 to 4 of 4

Thread: How to avoid this exception?

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to avoid this exception?

    I am using char** variable to download a file from http and save it in local disk. I have used char* variable and used calloc() and malloc() to allocate memory and free it after its usage.Also used a file for logging concept. I have used pixmap to set background for the dialog. Everything works fine. But after sometime. i get this error.. control automatically goes to this system QT file. and gives segmentation fault error.How to fix this?

    Qt Code:
    1. QClipData::~QClipData()
    2. {
    3. if(m_clipLines)
    4. free(m_clipLines);
    5. if(m_spans)
    6. free(m_spans);
    7. }
    To copy to clipboard, switch view to plain text mode 

    Sometimes, it shows this error and control goes here: Why it is happening?

    Qt Code:
    1. QImageData::~QImageData()
    2. {
    3. if(is_cached)
    4. QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no)<<32) | ((qint64) detach_no):
    5. delete paintEngine:
    6. if(data && own_data)
    7. free(data);
    To copy to clipboard, switch view to plain text mode 

    And sometimes, it gives the exception and the control goes here.

    Qt Code:
    1. Dump of assembler code for function ntdll!RtlEqualPrefixSid:
    2. 0x77543aac <+0>: mov $0x890c568b,%eax
    3. 0x77543ab1 <+5>: push %ebp
    4. 0x77543ab2 <+6>: cwtl
    5. 0x77543ab3 <+7>: mov (%edx),%edx
    6. 0x77543ab5 <+9>: mov 0x4(%edi),%edi
    7. End of assembler dump.
    To copy to clipboard, switch view to plain text mode 
    Last edited by Gokulnathvc; 27th August 2012 at 09:09.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to avoid this exception?

    This question has nothing to do with Qt.

    You are using a null or invalid pointer in your code. Run the program in a debugger to find out.

  3. #3
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to avoid this exception?

    What I think is strange is that you use C and C++ (de)allocations intermixed (new/delete and malloc/free). Since you are programming in C++, there is no need to use malloc/free, better use new/delete. By using both, you have the risk of using the wrong deallocation compared to the allocation, which may lead to anything, including crashes.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to avoid this exception?

    Are the pointers your trying to delete really initialized?
    Don't mix new with free and alloc with delete.
    Since you are in a C++ environment, use only new and delete.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. How to avoid border of QCanvas
    By olzzen in forum Qt Programming
    Replies: 3
    Last Post: 12th August 2010, 08:57
  2. Replies: 1
    Last Post: 28th June 2010, 06:21
  3. How can I avoid a QDialog close?
    By ricardo in forum Qt Programming
    Replies: 7
    Last Post: 11th May 2009, 19:29
  4. Avoid widget in taskbar
    By bunjee in forum Qt Programming
    Replies: 0
    Last Post: 5th May 2008, 22:18
  5. exception
    By AnithaRagupathy in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 09:59

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.