<?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>124722</bug_id>
          
          <creation_ts>2013-11-21 10:12:06 -0800</creation_ts>
          <short_desc>[EFL] X11Helper::createPixmap doesn&apos;t initialise out value handleId</short_desc>
          <delta_ts>2013-11-25 15:53:16 -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 EFL</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>1</everconfirmed>
          <reporter name="Simon Pena">spena</reporter>
          <assigned_to name="Simon Pena">spena</assigned_to>
          <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>kenneth</cc>
    
    <cc>laszlo.gombos</cc>
    
    <cc>lucas.de.marchi</cc>
    
    <cc>luiz</cc>
    
    <cc>noam</cc>
    
    <cc>zeno</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>953153</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Pena">spena</who>
    <bug_when>2013-11-21 10:12:06 -0800</bug_when>
    <thetext>Both 

void X11Helper::createPixmap(Pixmap* handleId, const XVisualInfo&amp; visualInfo, const IntSize&amp; size) and 
void X11Helper::createPixmap(Pixmap* handleId, const EGLint id, bool hasAlpha, const IntSize&amp; size) 

don&apos;t initialise the out parameter handleId.

The problem with that is that these functions do early returns under certain error situations, so clients using them could be checking an invalid value for handleId. At the moment, this is only call from EGLXSurface.cpp and GLXSurface.cpp, and while they could initialise themselves the argument before the call, I think that is error prone. I propose doing an early initialisation in createPixmap just to be on the safe side.

Patch following now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>953160</commentid>
    <comment_count>1</comment_count>
      <attachid>217581</attachid>
    <who name="Simon Pena">spena</who>
    <bug_when>2013-11-21 10:23:28 -0800</bug_when>
    <thetext>Created attachment 217581
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>953921</commentid>
    <comment_count>2</comment_count>
      <attachid>217581</attachid>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-11-25 01:37:51 -0800</bug_when>
    <thetext>Comment on attachment 217581
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=217581&amp;action=review

&gt; Source/WebCore/ChangeLog:13
&gt; +        be reliably checked for errors when the function returns.

Though I&apos;m not an expert in this area, I don&apos;t understand this description well. one of createPixmap() functions already supports error messages as below.

void X11Helper::createPixmap(Pixmap* handleId, const XVisualInfo&amp; visualInfo, const IntSize&amp; size)
{
    Display* display = nativeDisplay();
    if (!display)
        return;

    if (!visualInfo.visual) {
        LOG_ERROR(&quot;Failed to find valid XVisual.&quot;);
        return;
    }

    Window xWindow = offscreenRootWindow();
    if (!xWindow) {
        LOG_ERROR(&quot;Failed to create offscreen root window.&quot;);
        return;
    }

    Pixmap tempHandleId = XCreatePixmap(display, xWindow, size.width(), size.height(), visualInfo.depth);

    if (!tempHandleId) {
        LOG_ERROR(&quot;Failed to create offscreen pixmap.&quot;);
        return;
    }

    *handleId = tempHandleId;
    XSync(X11Helper::nativeDisplay(), false);

...

If we need to handle error situations for all createPixmap(), aren&apos;t we just add error messages in the other function as well ?


Could you explain what is benefit when initializing *handleId ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>953928</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pena">spena</who>
    <bug_when>2013-11-25 01:57:11 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 217581 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=217581&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/ChangeLog:13
&gt; &gt; +        be reliably checked for errors when the function returns.
&gt; 
&gt; Though I&apos;m not an expert in this area, I don&apos;t understand this description well. one of createPixmap() functions already supports error messages as below.

...

&gt; ...
&gt; 
&gt; If we need to handle error situations for all createPixmap(), aren&apos;t we just add error messages in the other function as well ?
&gt; 
&gt; 
&gt; Could you explain what is benefit when initializing *handleId ?

The problem with that approach is that we rely on error messages that will be seen in runtime. Since the function doesn&apos;t return false, or give any other hint that it failed, in runtime you cannot really check if everything is going fine.

When properly initialising handleId, the clients consuming the API which are currently doing 

if (!handleId)
   doSomething()

will be able to manage the error in a proper way. At the moment, that kind of checks is wrong: as handleId hasn&apos;t been initialised, it can have any value.

So my point is: ensuring handleId is initialised, its clients can safely use it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>953929</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Pena">spena</who>
    <bug_when>2013-11-25 01:57:50 -0800</bug_when>
    <thetext>In my first paragraph, I meant that the error messages go to the console, but you cannot really use them in the logic of the clients using that method.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>953931</commentid>
    <comment_count>5</comment_count>
      <attachid>217581</attachid>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-11-25 02:21:33 -0800</bug_when>
    <thetext>Comment on attachment 217581
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=217581&amp;action=review

&gt;&gt;&gt; Source/WebCore/ChangeLog:13
&gt;&gt;&gt; +        be reliably checked for errors when the function returns.
&gt;&gt; 
&gt;&gt; Though I&apos;m not an expert in this area, I don&apos;t understand this description well. one of createPixmap() functions already supports error messages as below.
&gt;&gt; 
&gt;&gt; void X11Helper::createPixmap(Pixmap* handleId, const XVisualInfo&amp; visualInfo, const IntSize&amp; size)
&gt;&gt; {
&gt;&gt;     Display* display = nativeDisplay();
&gt;&gt;     if (!display)
&gt;&gt;         return;
&gt;&gt; 
&gt;&gt;     if (!visualInfo.visual) {
&gt;&gt;         LOG_ERROR(&quot;Failed to find valid XVisual.&quot;);
&gt;&gt;         return;
&gt;&gt;     }
&gt;&gt; 
&gt;&gt;     Window xWindow = offscreenRootWindow();
&gt;&gt;     if (!xWindow) {
&gt;&gt;         LOG_ERROR(&quot;Failed to create offscreen root window.&quot;);
&gt;&gt;         return;
&gt;&gt;     }
&gt;&gt; 
&gt;&gt;     Pixmap tempHandleId = XCreatePixmap(display, xWindow, size.width(), size.height(), visualInfo.depth);
&gt;&gt; 
&gt;&gt;     if (!tempHandleId) {
&gt;&gt;         LOG_ERROR(&quot;Failed to create offscreen pixmap.&quot;);
&gt;&gt;         return;
&gt;&gt;     }
&gt;&gt; 
&gt;&gt;     *handleId = tempHandleId;
&gt;&gt;     XSync(X11Helper::nativeDisplay(), false);
&gt;&gt; 
&gt;&gt; ...
&gt;&gt; 
&gt;&gt; If we need to handle error situations for all createPixmap(), aren&apos;t we just add error messages in the other function as well ?
&gt;&gt; 
&gt;&gt; 
&gt;&gt; Could you explain what is benefit when initializing *handleId ?
&gt; 
&gt; ...

Ok, I understand what concern you point out. Caller can&apos;t check if pixmap is null under current implementation. r=me. However, it would be good if graphics folk take a look this finally before landing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>954144</commentid>
    <comment_count>6</comment_count>
      <attachid>217581</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-11-25 15:53:13 -0800</bug_when>
    <thetext>Comment on attachment 217581
Patch

Clearing flags on attachment: 217581

Committed r159772: &lt;http://trac.webkit.org/changeset/159772&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>954145</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-11-25 15:53:16 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>217581</attachid>
            <date>2013-11-21 10:23:28 -0800</date>
            <delta_ts>2013-11-25 15:53:13 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-124722-20131121182308.patch</filename>
            <type>text/plain</type>
            <size>2154</size>
            <attacher name="Simon Pena">spena</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTU5NjI5CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggOGJlMDFmYjdkMDI1ZDBm
MDhlNzMyMzg2NWFiYzk3YTYxZTU4YmZmMy4uYWY1ODdlZjhlN2MwYzI0OWRiZDQwMDdjMGVhNTkx
ZWZhMWFjOTkzMSAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDIwIEBACisyMDEzLTExLTIxICBTaW1v
biBQZW5hICA8c2ltb24ucGVuYUBzYW1zdW5nLmNvbT4KKworICAgICAgICBbRUZMXSBYMTFIZWxw
ZXI6OmNyZWF0ZVBpeG1hcCBkb2Vzbid0IGluaXRpYWxpc2Ugb3V0IHZhbHVlIGhhbmRsZUlkCisg
ICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xMjQ3MjIKKwor
ICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBUaGUgb3Zlcmxv
YWRlZCBmdW5jdGlvbnMgWDExSGVscGVyOjpjcmVhdGVQaXhtYXAgZG9uJ3QgaW5pdGlhbGlzZSBv
dX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