Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Invalid memory access error
Forum Updated to NodeBB v4.3 + New Features

Invalid memory access error

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arvind2111
    wrote on last edited by
    #1

    Hi,

    I'm using qt-jambi to develop an app that goes through a list of URLs, loads them in a QtWebView page and then parses them for links. To force the app to be synchronous (i.e. completely finish with one page before moving onto the next), we exec a QEventLoop. In the event that a page takes too long to load, we have a timer that fires 30 seconds and forces the app to move on. However, after some random number of URLs, the app always segfaults and points to a different part of libQtWebkit. For example:

    C [libQtWebKit.so.4+0x3ff181] WTF::TCMalloc_Central_FreeList::FetchFromSpans()+0x31

    C [libQtWebKit.so.4+0x87d239] WebCore::QNetworkReplyHandler::sendResponseIfNeeded()+0xa09

    and so forth.

    What's interesting is if, in the loadFinished slot, we comment out the code that parses the page for links, there is never a segfault. Any ideas would be appreciated. A slimmed down version of the code is below or at http://pastiebin.com/?page=p&id=4f5bb860922e6

    Thanks!

    -Arvind

    @public class PostProcess extends QMainWindow {
    private QEventLoop mLoop;
    private QWebView mBrowser;
    private QTimer mTimer;

    private String[] mPageData;
    private int mPageIndex;
    
    public PostProcess() {
            this(null);
        }
    
    public PostProcess(QWidget parent) {
        super(parent);
    
        mLoop = new QEventLoop();
    
        mBrowser = new QWebView();
        setCentralWidget(mBrowser);
    
        mTimer = new QTimer();
        mTimer.setInterval(1000 * 30);
        mTimer.setSingleShot(true);
        mTimer.timeout.connect(this, "pageTimedOut()");
    }
    
    public static void main(String[] args) throws InterruptedException, IOException {          
        QApplication.initialize(args);
        
        PostProcess pp = new PostProcess();
        
        pp.run();
        
        QApplication.exit();
    }
    
    private void postProcess() {
        while (mPageIndex < mPageData.length) {
            String uri    = mPageData[mPageIndex];
    
            QNetworkAccessManager manager = new PostProcessNetworkAccessManager(pageId);
            mBrowser.page().setNetworkAccessManager(manager);
            mBrowser.page().settings().clearMemoryCaches();
            mBrowser.loadFinished.connect(this, "loadFinished(Boolean)");
            mBrowser.loadProgress.connect(this, "loadProgress(int)");
            
            QNetworkRequest req = new QNetworkRequest(new QUrl("http://" + uri));
            req.setRawHeader(FROM_CACHE, new QByteArray("1"));
            req.setRawHeader(PAGE_ID, new QByteArray(pageId));
            
            mTimer.start();
            
            mBrowser.load(req);
            
            mLoop.exec&#40;&#41;;   
            
            mPageIndex++;
        }
    }
    
    private void loadFinished(Boolean ok) { 
        debug("LOAD FINISHED: " + mBrowser.url() + " " + ok);
        mTimer.stop();
    
        mBrowser.loadFinished.disconnect();
        mBrowser.loadProgress.disconnect();
        mBrowser.stop();
    
        if(ok == true) {
            QWebElementCollection anchors = page.mainFrame().findAllElements("a");
         for(QWebElement anchor: anchors.toList())
             nextURIs.add(anchor.attribute("href"));
        }
    
        mLoop.exit();
    }
    
    private void loadProgress(int i) {
        System.err.print(i + "...");
    }
    
    private void pageTimedOut() {
        debug("TIMED OUT PAGE LOAD " + mBrowser.url());
        mBrowser.loadFinished.disconnect();
        mBrowser.loadProgress.disconnect();
    
        mBrowser.load(new QUrl("about:blank"));
        mLoop.exit();
    }@
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved