<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - PlatformDisplay crash when calling egl_terminate"
   href="https://bugs.webkit.org/show_bug.cgi?id=157973#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - PlatformDisplay crash when calling egl_terminate"
   href="https://bugs.webkit.org/show_bug.cgi?id=157973">bug 157973</a>
              from <span class="vcard"><a class="email" href="mailto:zan&#64;falconsigh.net" title="Zan Dobersek &lt;zan&#64;falconsigh.net&gt;"> <span class="fn">Zan Dobersek</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=280238&amp;action=diff" name="attach_280238" title="Updated patch">attachment 280238</a> <a href="attachment.cgi?id=280238&amp;action=edit" title="Updated patch">[details]</a></span>
Updated patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=280238&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=280238&amp;action=review</a>

<span class="quote">&gt;&gt; Source/WebCore/platform/graphics/PlatformDisplay.cpp:169
&gt;&gt; +    std::atexit([] { PlatformDisplay::sharedDisplay().terminateEGLDisplay(); });
&gt; 
&gt; Since this is not a static function, I think it make more sense to not use PlatformDisplay::sharedDisplay() here. You say you cannot capture |this| here, but I don't understand why not; did you try writing it this way:
&gt; 
&gt; std::atexit([this] { this-&gt;terminateEGLDisplay(); });</span >

std::atexit() has to be passed a function pointer to a static function, since it only stores the pointer, not the whole function object.

Only capture-less lambdas can be passed as such arguments, since they have the conversion operator that converts to a function pointer.
<a href="http://en.cppreference.com/w/cpp/language/lambda">http://en.cppreference.com/w/cpp/language/lambda</a> -- see ClosureType::operator ret(*)(params)()

In such cases compiler simply generates a bare struct with the call operator and this conversion operator, since it has no state to manage because nothing is captured. You'd basically be able to call the struct's call operator as if it was any other static non-method function. If anything is captured, then lambda implies an actual object of that helper struct type, generating all the relevant constructors and destructors, plus you have to address the lifetime management (limited to scope or storable to std::function&lt;&gt; for delayed use).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>