<?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>38263</bug_id>
          
          <creation_ts>2010-04-28 07:42:08 -0700</creation_ts>
          <short_desc>[Gtk] DNS prefetching trying to resolve empty host names, spamming syslog</short_desc>
          <delta_ts>2011-05-12 06:12:46 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Michael Gratton">mike</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>gustavo</cc>
    
    <cc>svillar</cc>
    
    <cc>xan.lopez</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>218393</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Gratton">mike</who>
    <bug_when>2010-04-28 07:42:08 -0700</bug_when>
    <thetext>WebKitGTK+ v1.2.0 (Ubuntu lucid libwebkit-1.0-2 1.2.0-1)

Webkit is causing programs that embed it to spam syslog with this sort of thing:

&gt; Apr 29 00:17:01 localhost epiphany-browser: gethostby*.getanswer: asked for &quot;&quot;, got &quot;.&quot;
&gt; Apr 29 00:18:07 localhost epiphany-browser: last message repeated 527 times
&gt; Apr 29 00:19:08 localhost epiphany-browser: last message repeated 1178 times
&gt; Apr 29 00:20:09 localhost epiphany-browser: last message repeated 1300 times
&gt; Apr 29 00:21:18 localhost epiphany-browser: last message repeated 1341 times
&gt; Apr 29 00:22:27 localhost epiphany-browser: last message repeated 715 times
&gt; Apr 29 00:23:27 localhost epiphany-browser: last message repeated 1307 times
&gt; Apr 29 00:24:27 localhost epiphany-browser: last message repeated 863 times
&gt; Apr 29 00:25:27 localhost epiphany-browser: last message repeated 989 times
&gt; Apr 29 00:26:27 localhost epiphany-browser: last message repeated 534 times

It looks like the DNS prefetching code is causing null/empty host names to be resolved, which explains the syslog entry. A typical stack trace is below. Note the call to g_resolver_lookup_by_name_async at the top with an empty hostname param.

I&apos;m not sure where the best place to guard against this is, perhaps both GIO and Soup should be ignoring/erroring when invoked to resolve an empty host name, but libwebkitgtk probably shouldn&apos;t be attempting to prefetch links without a valid URI host part anyway.

#0  IA__g_resolver_lookup_by_name_async (resolver=0x20ef780, 
    hostname=0x39cace0 &quot;&quot;, cancellable=0x0, callback=0x7fac17c2a2a0, 
    user_data=0x3516450) at /build/buildd/glib2.0-2.24.0/gio/gresolver.c:299
#1  0x00007fac17c2a18d in soup_address_resolve_async ()
   from /usr/lib/libsoup-2.4.so.1
#2  0x00007fac1904ee49 in WebCore::prefetchDNS (hostname=&lt;value optimised out&gt;)
    at ../WebCore/platform/network/soup/DNSSoup.cpp:44
#3  0x00007fac18d11670 in WebCore::Chrome::mouseDidMoveOverElement (
    this=0x7fabfd8e63c0, result=..., modifierFlags=27303232)
    at ../WebCore/page/Chrome.cpp:340
#4  0x00007fac18d2bd46 in WebCore::EventHandler::mouseMoved (
    this=&lt;value optimised out&gt;, event=...)
    at ../WebCore/page/EventHandler.cpp:1332
#5  0x00007fac19084055 in webkit_web_view_motion_event (
    widget=&lt;value optimised out&gt;, event=0x7fabe5c9a350)
    at ../WebKit/gtk/webkit/webkitwebview.cpp:654
#6  0x00007fac17fab0b8 in _gtk_marshal_BOOLEAN__BOXED (closure=0x1a09d40, 
    return_value=0x7fffad3488b0, n_param_values=&lt;value optimised out&gt;, 
    param_values=0x429a320, invocation_hint=&lt;value optimised out&gt;, 
    marshal_data=0x7fac19083ff0)
    at /build/buildd/gtk+2.0-2.20.0/gtk/gtkmarshalers.c:84
#7  0x00007fac16d925de in IA__g_closure_invoke (closure=0x1a09d40, 
    return_value=0x7fffad3488b0, n_param_values=2, param_values=0x429a320, 
---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
    invocation_hint=0x7fffad348870)
    at /build/buildd/glib2.0-2.24.0/gobject/gclosure.c:767
#8  0x00007fac16da61dd in signal_emit_unlocked_R (node=0x1a09db0, 
    detail=&lt;value optimised out&gt;, instance=&lt;value optimised out&gt;, 
    emission_return=&lt;value optimised out&gt;, 
    instance_and_params=&lt;value optimised out&gt;)
    at /build/buildd/glib2.0-2.24.0/gobject/gsignal.c:3286
#9  0x00007fac16da78b9 in IA__g_signal_emit_valist (instance=0x7fabe5e2c810, 
    signal_id=&lt;value optimised out&gt;, detail=0, var_args=0x7fffad348a60)
    at /build/buildd/glib2.0-2.24.0/gobject/gsignal.c:2991
#10 0x00007fac16da8033 in IA__g_signal_emit (instance=0x20ef780, 
    signal_id=60599520, detail=0)
    at /build/buildd/glib2.0-2.24.0/gobject/gsignal.c:3038
#11 0x00007fac180c1e9f in gtk_widget_event_internal (widget=0x7fabe5e2c810, 
    event=0x7fabe5c9a350) at /build/buildd/gtk+2.0-2.20.0/gtk/gtkwidget.c:4951
#12 0x00007fac17fa3583 in IA__gtk_propagate_event (widget=0x7fabe5e2c810, 
    event=0x7fabe5c9a350) at /build/buildd/gtk+2.0-2.20.0/gtk/gtkmain.c:2447
#13 0x00007fac17fa465b in IA__gtk_main_do_event (event=0x7fabe5c9a350)
    at /build/buildd/gtk+2.0-2.20.0/gtk/gtkmain.c:1647
#14 0x00007fac179c580c in gdk_event_dispatch (source=&lt;value optimised out&gt;, 
    callback=&lt;value optimised out&gt;, user_data=&lt;value optimised out&gt;)
    at /build/buildd/gtk+2.0-2.20.0/gdk/x11/gdkevents-x11.c:2372
#15 0x00007fac166dd8c2 in g_main_dispatch (context=0x1a06310)
---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
    at /build/buildd/glib2.0-2.24.0/glib/gmain.c:1960
#16 IA__g_main_context_dispatch (context=0x1a06310)
    at /build/buildd/glib2.0-2.24.0/glib/gmain.c:2513
#17 0x00007fac166e1748 in g_main_context_iterate (context=0x1a06310, 
    block=&lt;value optimised out&gt;, dispatch=&lt;value optimised out&gt;, 
    self=&lt;value optimised out&gt;)
    at /build/buildd/glib2.0-2.24.0/glib/gmain.c:2591
#18 0x00007fac166e1c55 in IA__g_main_loop_run (loop=0x1ab9fb0)
    at /build/buildd/glib2.0-2.24.0/glib/gmain.c:2799
#19 0x00007fac17fa4af7 in IA__gtk_main ()
    at /build/buildd/gtk+2.0-2.20.0/gtk/gtkmain.c:1219
#20 0x0000000000435423 in main (argc=1, argv=0x7fffad349fd8)
    at /build/buildd/epiphany-browser-2.30.2/src/ephy-main.c:741</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>218473</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-04-28 10:52:10 -0700</bug_when>
    <thetext>We have the following in DNSCFNet.cpp (used in CFNetwork-based ports):

    if (hostname.isEmpty())
        return;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>219321</commentid>
    <comment_count>2</comment_count>
      <attachid>54769</attachid>
    <who name="Michael Gratton">mike</who>
    <bug_when>2010-04-29 18:39:39 -0700</bug_when>
    <thetext>Created attachment 54769
Check hostname is non-empty before DNS prefetch

Per Alexey&apos;s suggestion, this adds an empty check on the hostname string before calling Soup to prefetch.

This patch fixes the problem for me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>299364</commentid>
    <comment_count>3</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2010-10-26 03:07:33 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Created an attachment (id=54769) [details]
&gt; Check hostname is non-empty before DNS prefetch
&gt; 
&gt; Per Alexey&apos;s suggestion, this adds an empty check on the hostname string before calling Soup to prefetch.
&gt; 
&gt; This patch fixes the problem for me.

Michael could you please include the proper changelog to the patch? There is some infor here http://webkit.org/coding/contributing.html. And do not forget to set the review flag to &quot;?&quot;.

Adding Xan to the Cc BTW</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>382771</commentid>
    <comment_count>4</comment_count>
    <who name="Gustavo Noronha (kov)">gustavo</who>
    <bug_when>2011-04-09 05:14:36 -0700</bug_when>
    <thetext>Is this now obsolete? After 56128 the way this is done is completely different for the GTK+ port, and I was unable to identify at a glance if we would still be able to suffer from the same problem. Can the URL passed to prepareForURL lack a host?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>402454</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Gratton">mike</who>
    <bug_when>2011-05-11 17:18:45 -0700</bug_when>
    <thetext>I&apos;m not getting the syslog spam any more with webkit 1.4, soup 2.34 and glib  2.28, but I guess that&apos;s not to say the problem isn&apos;t still there.

Gustavo, bug #56128 doesn&apos;t seem relevant?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>402458</commentid>
    <comment_count>6</comment_count>
    <who name="Gustavo Noronha (kov)">gustavo</who>
    <bug_when>2011-05-11 17:24:37 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; Gustavo, bug #56128 doesn&apos;t seem relevant?

I meant revision 56128: http://trac.webkit.org/changeset/56128</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>402538</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Gratton">mike</who>
    <bug_when>2011-05-11 18:37:13 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; 
&gt; I meant revision 56128: http://trac.webkit.org/changeset/56128

Oh, of course, thanks.

Well, that revision uses soup_session_prepare_for_uri() for the DNS prefetching, and that function (in libsoup git master anyway) does a null check on the host, so this can probably be resolved as invalid or wontfix now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>402555</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Gratton">mike</who>
    <bug_when>2011-05-11 19:19:43 -0700</bug_when>
    <thetext>One note, possibly for another bug: Since HTMLAnchorElement::parseMappedAttribute calls ResourceHandle::prepareForURL, whenever an anchor element&apos;s href attribute is changed (which I assume also happens when the element is first parsed), loading a page will cause every anchor&apos;s href to be prefetched.

This doesn&apos;t strike me as being very desirable, but I guess that is a WebKit issue in general.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>402799</commentid>
    <comment_count>9</comment_count>
    <who name="Gustavo Noronha (kov)">gustavo</who>
    <bug_when>2011-05-12 06:12:46 -0700</bug_when>
    <thetext>Well, fixed, just by a different patch, then =)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>54769</attachid>
            <date>2010-04-29 18:39:39 -0700</date>
            <delta_ts>2010-06-11 11:46:50 -0700</delta_ts>
            <desc>Check hostname is non-empty before DNS prefetch</desc>
            <filename>webkit-empty-hostname.patch</filename>
            <type>text/plain</type>
            <size>467</size>
            <attacher name="Michael Gratton">mike</attacher>
            
              <data encoding="base64">LS0tIFdlYkNvcmUvcGxhdGZvcm0vbmV0d29yay9zb3VwL0ROU1NvdXAuY3BwLW9yaWcJMjAxMC0w
NC0yOSAwMToyNjowNi4wNDg3MjU0MTkgKzEwMDAKKysrIFdlYkNvcmUvcGxhdGZvcm0vbmV0d29y
ay9zb3VwL0ROU1NvdXAuY3BwCTIwMTAtMDQtMjkgMTQ6Mjg6NTUuNzMxNDcxMDI1ICsxMDAwCkBA
IC0zNiw2ICszNiw4IEBACiB2b2lkIHByZWZldGNoRE5TKGNvbnN0IFN0cmluZyYgaG9zdG5hbWUp
CiB7CiAjaWZkZWYgSEFWRV9MSUJTT1VQXzJfMjlfOTAKKyAgICBpZiAoaG9zdG5hbWUuaXNFbXB0
eSgpKQorICAgICAgICByZXR1cm47CiAgICAgU3RyaW5nIHVyaSA9ICJodHRwOi8vIitob3N0bmFt
ZTsKICAgICBHT3duUHRyPFNvdXBVUkk+IHNvdXBVUkkoc291cF91cmlfbmV3KHVyaS51dGY4KCku
ZGF0YSgpKSk7CiAgICAgLy8gV2UgbWF5IGdldCBpbnZhbGlkIGhvc3RuYW1lcywgc28gTlVMTC1j
aGVjayBoZXJlLgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>