<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Variant can crash when constructed with default constructor"
   href="https://bugs.webkit.org/show_bug.cgi?id=165568">165568</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Variant can crash when constructed with default constructor
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Web Template Framework
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>krollin&#64;apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>krollin&#64;apple.com, sam&#64;webkit.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given the following struct:

struct MyStruct {
    MyStruct(Vector&lt;String&gt; val) : m_vector(val) {}
    Vector&lt;String&gt; m_vector;                                                                                                                                                                            
};  

The following will crash in the WTF::Variant destructor:

{
    WTF::Variant&lt;MyStruct&gt; temp;
}

Here's the backtrace:

0     WTF::RefPtr&lt;WTF::StringImpl&gt;::~RefPtr() + 67 (utility:754)
1     WTF::RefPtr&lt;WTF::StringImpl&gt;::~RefPtr() + 21 (RefPtr.h:62)
2     WTF::String::~String() + 21 (WTFString.h:137)
3     WTF::String::~String() + 21 (WTFString.h:137)
4     WTF::VectorDestructor&lt;true, WTF::String&gt;::destruct(WTF::String*, WTF::String*) + 47 (Vector.h:59)
5     WTF::VectorTypeOperations&lt;WTF::String&gt;::destruct(WTF::String*, WTF::String*) + 29 (Vector.h:225)
6     WTF::Vector&lt;WTF::String, 0ul, WTF::CrashOnOverflow, 16ul&gt;::shrink(unsigned long) + 132 (Vector.h:1026)
7     WTF::Vector&lt;WTF::String, 0ul, WTF::CrashOnOverflow, 16ul&gt;::~Vector() + 43 (Vector.h:631)
8     WTF::Vector&lt;WTF::String, 0ul, WTF::CrashOnOverflow, 16ul&gt;::~Vector() + 21 (Vector.h:634)
9     WebKit::NetworkCapture::MyStruct::~MyStruct() + 21 (NetworkCaptureManager.cpp:64)
10    WebKit::NetworkCapture::MyStruct::~MyStruct() + 21 (NetworkCaptureManager.cpp:64)
11    WTF::__storage_wrapper&lt;WebKit::NetworkCapture::MyStruct&gt;::__destroy() + 29 (Variant.h:444)
12    WTF::__variant_storage&lt;WebKit::NetworkCapture::MyStruct, false&gt;::__destroy(WTF::__storage_wrapper&lt;WebKit::NetworkCapture::MyStruct&gt;&amp;) + 21 (Variant.h:481)
13    WTF::__variant_data&lt;WebKit::NetworkCapture::MyStruct&gt;::__destroy(WTF::in_place_tag (&amp;)(WTF::__in_place_private::__value_holder&lt;0ul&gt;&amp;)) + 28 (Variant.h:552)
14    void WTF::__destroy_op_table&lt;WTF::Variant&lt;WebKit::NetworkCapture::MyStruct&gt;, WTF::__index_sequence&lt;0l&gt; &gt;::__destroy_func&lt;0l&gt;(WTF::Variant&lt;WebKit::NetworkCapture::MyStruct&gt;*) + 45 (Variant.h:827)
15    WTF::Variant&lt;WebKit::NetworkCapture::MyStruct&gt;::__destroy_self() + 77 (Variant.h:1471)
16    WTF::__variant_base&lt;WTF::Variant&lt;WebKit::NetworkCapture::MyStruct&gt;, false&gt;::~__variant_base() + 21 (Variant.h:923)
17    WTF::Variant&lt;WebKit::NetworkCapture::MyStruct&gt;::~Variant() + 21 (Variant.h:1439)
18    WTF::Variant&lt;WebKit::NetworkCapture::MyStruct&gt;::~Variant() + 21 (Variant.h:1439)

The Variant default constructor is suppose to create an instance of its first type, so the fact that we're destructing one seems proper. Since the destruction is failing, I guess that the object wasn't properly created in the first place. I also note that MyStruct does not have a default constructor, so I don't know how Variant is creating one in the first place. And I don't know why a WTF::String is being destructed since the Vector should be empty.</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>