<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>90008</bug_id>
          
          <creation_ts>2012-06-26 13:21:05 -0700</creation_ts>
          <short_desc>[Qt] Assertion reached when accessing mainFrame()-&gt;setHTML(&quot;&quot;); from QWebPage</short_desc>
          <delta_ts>2014-01-13 21:46:22 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Qt</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows 7</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Viv Rajkumar">viv.rajkumar</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>andersca</cc>
    
    <cc>TriumphSprint2000</cc>
    
    <cc>viv.rajkumar</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>657915</commentid>
    <comment_count>0</comment_count>
    <who name="Viv Rajkumar">viv.rajkumar</who>
    <bug_when>2012-06-26 13:21:05 -0700</bug_when>
    <thetext>Heya,

Qt Version: 4.8.2
My Machine: Windows 7 (x86)
Build Type: Release
Compiler: Visual Studio 2012 RC


Problem currently is QtWebKit4.dll crashes *ONLY* in x86 Release mode (Have tested Debug and x64 both types) on calling mainFrame()-&gt;setHtml(&quot;anything&quot;) from inside a subclassed QWebPage constructor.


Have noticed this problem presents itself also on QT-WebKit examples like &quot;previewer&quot;, &quot;domtraversal&quot; again only in release mode.


I built the debugging symbols for Release QtWebKit4.dll to identify the origin of this error and found it at:

File: TextEncodingRegistry.cpp (Line 333) 

PassOwnPtr&lt;TextCodec&gt; newTextCodec(const TextEncoding&amp; encoding)
{
  ...
  return factory.function(encoding, factory.additionalData);
}

In factory.functor assertion is triggered even though just above it there is an assert making sure it&apos;s not invalid (I&apos;m not able to step any further into the code to debug it)


Call-Stack I got from Visual Studio:

00000000()	
&gt;	QtWebKit4.dll!WebCore::newTextCodec(const WebCore::TextEncoding &amp; encoding)  Line 333 + 0x24 bytes	C++
 	QtWebKit4.dll!WebCore::TextResourceDecoder::flush()  Line 685 + 0xd bytes	C++
 	QtWebKit4.dll!WebCore::DecodedDataDocumentParser::appendBytes(WebCore::DocumentWriter * writer, const char * data, int length, bool shouldFlush)  Line 48 + 0xb bytes	C++
 	QtWebKit4.dll!WebCore::DocumentWriter::endIfNotLoadingMainResource()  Line 229	C++
 	QtWebKit4.dll!WebCore::FrameLoader::init()  Line 239	C++
 	QtWebKit4.dll!QWebFrame::QWebFrame(QWebPage * parent, QWebFrameData * frameData)  Line 540	C++
 	QtWebKit4.dll!QWebPagePrivate::createMainFrame()  Line 426 + 0x23 bytes	C++
 	QtWebKit4.dll!QWebPage::mainFrame()  Line 2003	C++




To Reproduce Problem:
1.a. Either just call setHtml() on QWebView or QWebPage()-&gt;mainFrame() from release in the current build environment.
1.b. QT-Examples &quot;previewer&quot;, &quot;domtraversal&quot; also have this problem in release.



Possible WorkAround:
1. Have been trying to find a workaround currently until an offical fix is available by trying to set the QWebPage&apos;s defaultTextCodec() from code before setHtml() is called. That does not work though, the if condition still fails and goes to the newTextCodec function


Thank you,

Viv</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>661182</commentid>
    <comment_count>1</comment_count>
    <who name="Viv Rajkumar">viv.rajkumar</who>
    <bug_when>2012-07-01 16:10:43 -0700</bug_when>
    <thetext>Seems to be a problem with the -&gt;get() function of HashMap.h &amp; MSVC 2012

Does not seem to like key&apos;s with an uppercase character as the first character.

Managed to fix it by avoiding the get() function in TextEncodingRegistry.cpp


In:

static void addToTextCodecMap(const char* name, NewTextCodecFunction function, const void* additionalData)


Replaced:

const char* atomicName = textEncodingNameMap-&gt;get(name);

With:

const char* atomicName;
TextEncodingNameMap::iterator pos;
for (pos = textEncodingNameMap-&gt;begin(); pos != textEncodingNameMap-&gt;end(); ++pos) {
  if (strcmp(pos-&gt;first, name) == 0) {
    atomicName = pos-&gt;second;
    break;
  }
}

And In:

PassOwnPtr&lt;TextCodec&gt; newTextCodec(const TextEncoding&amp; encoding)

Replaced:

TextCodecFactory factory = textCodecMap-&gt;get(encoding.name());

With:

TextCodecFactory factory;
TextCodecMap::iterator pos;
for (pos = textCodecMap-&gt;begin(); pos != textCodecMap-&gt;end(); ++pos) {
  if (strcmp(pos-&gt;first, encoding.name()) == 0) {
    factory = pos-&gt;second;
    break;
  }
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>860260</commentid>
    <comment_count>2</comment_count>
    <who name="Jeff">TriumphSprint2000</who>
    <bug_when>2013-03-21 05:59:08 -0700</bug_when>
    <thetext>I can confirm that this is still a problem On Windows 7 VS2012 Release build.

It appears that atomicCanonicalTextEncodingName is executing when an access violation occurs, due to deref&apos;ing a null pointer. Several related &apos;this&apos; pointers have become null. 

The code is difficult to debug with /O2 optimizations, as lots of code is relocated, particularly mutex locking. So I built with /O1 and lo-and-behold no access violations. I also tried /Ox which but this gives the same result as /O2.

So a workaround is to compile WebCore with /O1 optimization flag.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>