Boost C++ Libraries: Ticket #11360: Undefined behavior in extended_type_info_typeid default constructor? https://svn.boost.org/trac10/ticket/11360 <p> Using the undefined behavior sanitizer I probably hit the same problem as <a class="reopened ticket" href="https://svn.boost.org/trac10/ticket/11204" title="#11204: Bugs: undefined behavior sanitizer complains about runtime_error thrown in ... (reopened)">#11204</a> </p> <p> However, I also got another message: </p> <pre class="wiki">/usr/include/boost/serialization/extended_type_info_typeid.hpp:87:59: runtime error: member call on address 0x0000010adb60 which does not point to an object of type 'extended_type_info_typeid' 0x0000010adb60: note: object has invalid vptr 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ invalid vptr </pre><p> Maybe this message triggers the following messages (as described in <a class="reopened ticket" href="https://svn.boost.org/trac10/ticket/11204" title="#11204: Bugs: undefined behavior sanitizer complains about runtime_error thrown in ... (reopened)">#11204</a>) </p> <p> Anyways, in extended_type_info_typeid.hpp I found </p> <div class="wiki-code"><div class="code"><pre><span class="n">extended_type_info_typeid</span><span class="p">()</span> <span class="o">:</span> <span class="n">typeid_system</span><span class="o">::</span><span class="n">extended_type_info_typeid_0</span><span class="p">(</span><span class="n">get_key</span><span class="p">())</span> <span class="c1">// &lt;--- line 87</span> <span class="p">{</span> <span class="c1">// ...</span> <span class="p">}</span> <span class="c1">// ...</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">get_key</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="c1">// &lt;--- line 108</span> <span class="k">return</span> <span class="n">boost</span><span class="o">::</span><span class="n">serialization</span><span class="o">::</span><span class="n">guid</span><span class="o">&lt;</span> <span class="n">T</span> <span class="o">&gt;</span><span class="p">();</span> <span class="p">}</span> </pre></div></div><p> As we can see, the member function <code>get_key</code> is called to initialize a base class. </p> <p> According to ยง 12.6.2.13 of the standard (I am using n3242) calling a member function in a ctor-initializer before all base classes have been initialized is undefined behavior. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11360 Trac 1.4.3 Robert Ramey Sun, 15 Nov 2015 07:16:33 GMT <link>https://svn.boost.org/trac10/ticket/11360#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11360#comment:1</guid> <description> <p> Made a change to fix this. It's been uploaded to the develop branch. So I'm going to mark this as fixed </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Sun, 15 Nov 2015 07:16:40 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11360#comment:2 https://svn.boost.org/trac10/ticket/11360#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> โ†’ <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> โ†’ <span class="trac-field-new">fixed</span> </li> </ul> Ticket anonymous Wed, 13 Jan 2016 15:08:54 GMT <link>https://svn.boost.org/trac10/ticket/11360#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11360#comment:3</guid> <description> <p> For posterity's sake: </p> <p> <a class="ext-link" href="https://github.com/boostorg/serialization/commit/4f83fc163afad8fc078afcb0eccfbda1f161b3b6"><span class="icon">โ€‹</span>https://github.com/boostorg/serialization/commit/4f83fc163afad8fc078afcb0eccfbda1f161b3b6</a> </p> <pre class="wiki">- typeid_system::extended_type_info_typeid_0(get_key()) + typeid_system::extended_type_info_typeid_0( + boost::serialization::guid&lt; T &gt;() + ) </pre><p> Just hit this myself and wanted to apply a patch locally. </p> </description> <category>Ticket</category> </item> </channel> </rss>