PDA

View Full Version : How to avoid this exception?



Gokulnathvc
27th August 2012, 08:34
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?


QClipData::~QClipData()
{
if(m_clipLines)
free(m_clipLines);
if(m_spans)
free(m_spans);
}

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


QImageData::~QImageData()
{
if(is_cached)
QImagePixmapCleanupHooks::executeImageHooks((((qin t64) ser_no)<<32) | ((qint64) detach_no):
delete paintEngine:
if(data && own_data)
free(data);

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


Dump of assembler code for function ntdll!RtlEqualPrefixSid:
0x77543aac <+0>: mov $0x890c568b,%eax
0x77543ab1 <+5>: push %ebp
0x77543ab2 <+6>: cwtl
0x77543ab3 <+7>: mov (%edx),%edx
0x77543ab5 <+9>: mov 0x4(%edi),%edi
End of assembler dump.

ChrisW67
27th August 2012, 09:30
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.

T_h_e_o
29th August 2012, 11:23
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.

high_flyer
29th August 2012, 11:26
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.