PDA

View Full Version : Webview and EXC_BAD_ACCESS



jdgrant
25th November 2011, 02:31
Hi everyone.

I did an override of NetworkReply to handle "tweeked" HTTP requests inside a Custom Network Access Manager in a webview. It works great for a web pages that do not have any images or javascript links. But as soon as a secondary image or javascript page is called the app crashes with a Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 error when using webkit.

The odd thing is the stack shows the error on a line that is not editable from me and appears to happen after the custom NetworkAccessManager returns back to the WebView.

I have been able to prove that each NetworkAccessManager and each Custom NetworkReply is using a different memory address, so I am not sure where error is coming from.

Has anyone seen something similar.

Jon

jdgrant
25th November 2011, 18:34
Ok, this is weird. I have narrowed the error to a line that it is in the MOC. I still can't figure out where the BAD ACCESS is coming from, but I am perplexed about the function in general.

This is what it produced. I am confused on what it's purpose is, especially the if _ID<0 then return the _id; else it returns the _id. What is the point of the IF?

How are these MOCs produced?

int QCustomNetworkReply::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QNetworkReply::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}

Thanks

Jon

Spitfire
28th November 2011, 10:33
Difficult to tell without looking at the code what's going wrong.
I guess that because you're accessing a network some async signal is trying to access a part of memory that it shouldn't.

MOC files are produced by meta-object compiler (http://doc.qt.nokia.com/stable/moc.html).

as to the qt_metacall function, it's how it looks when object has no signals/slots defined, it's just a scaffolding and it's there beacuse Q_OBJECT macro was defined in the header file.
(ps please use
tags)[CODE]int StatusProcess::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QProgressBar::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}as soon as you define some signal or slot the function will start to grow and will look something like that:
int StatusProcess::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QProgressBar::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: someSignal(); break;
case 1: someSlot(); break;
default: ;
}
_id -= 2;
}
return _id;
}