[webkit-dev] webFrame->loadRequest(...) fails with acces violation exception

Frank Thomsen fth at trifork.com
Thu Mar 5 01:17:04 PST 2009


Hi everyone

After uninstalling Safari and starting to explicitly loading the webkit.dll file I get a weird error when loading a URL request. Incidentally I get the same error the exact same place when I try to run the WinLauncher.exe application (which is part of the Windows port of WebKit).

(NOTE: error handling code and other clutter is removed from the following source)

First I load the DLL and gets a function pointer to the DllGetClassObject method (DllRegisterServer does nothing so registering the dll with RegSvr32.exe yields an error):

              hmodWebKit  = LoadLibrary(TEXT("WebKit.dll"));
              if (hmodWebKit)
                     dllGetClassObject = (DLLGETCLASSOBJECTFARPROC)GetProcAddress(hmodWebKit, "DllGetClassObject");
              if(!dllGetClassObject)
                     return false;

Then I get the class factory for a WebView, and instructs it to create an instance:

              IClassFactory* pClsFactory;
              if(FAILED(dllGetClassObject(CLSID_WebView, IID_IClassFactory, (void**)&pClsFactory)))
                     return false;
              IWebView* pWebView;
              classFactory->CreateInstance(NULL, IID_IWebView, (void**)&pWebView);

Now for the part where I will load a URL. I start by getting the main frame:

              IWebFrame* frame;
              webView->mainFrame(&frame);

Then I create a class factory for a mutable web request and instructs that factory to create a request for me:

              IWebMutableURLRequest* request;
              IClassFactory* pClsFct;
              dllGetClassObject(CLSID_WebMutableURLRequest, IID_IClassFactory, (void**)&pClsFct);
              pClsFct->CreateInstance(NULL, IID_IWebMutableURLRequest, (void**)&request);

I initialize the request like this:
              request->initWithURL(bstrUrl,WebURLRequestUseProtocolCachePolicy,60);

But when I instruct the frame to load the request, like this:
              frame->loadRequest(request);

I get an acces violation exception saying:
"Unhandled exception at 0x655452d5 in <app.name>.exe: 0xC0000005:
Access violation reading location 0x00000070."

The application breaks in StringImplCF.cpp, in the method "CFStringRef StringImpl::createCFString()" at this line:
    CFStringRef string = CFStringCreateWithCharactersNoCopy(allocator, reinterpret_cast<const UniChar*>(m_data), m_length, kCFAllocatorNull);

As previously mentioned it is the same error that I get when trying to run WinLauncher.exe. Does anyone know what the problem is?

Best regards,
Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090305/2c0d4829/attachment.html>


More information about the webkit-dev mailing list