{"id":1913,"date":"2014-01-31T07:00:00","date_gmt":"2014-01-31T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2014\/01\/31\/non-psychic-debugging-if-somebodys-complaining-that-a-collection-should-be-empty-but-isnt-you-might-want-to-see-whats-in-there\/"},"modified":"2014-01-31T07:00:00","modified_gmt":"2014-01-31T07:00:00","slug":"non-psychic-debugging-if-somebodys-complaining-that-a-collection-should-be-empty-but-isnt-you-might-want-to-see-whats-in-there","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20140131-00\/?p=1913","title":{"rendered":"Non-psychic debugging: If somebody&#039;s complaining that a collection should be empty but isn&#039;t, you might want to see what&#039;s in there"},"content":{"rendered":"<p>\nA programmer on the GHI team\n(yes,\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2014\/01\/24\/10492287.aspx\">\nthe same GHI team<\/a>)\nreported that they were hitting an assertion failure\nusing an internal library and asked for help debugging it.\n<\/p>\n<pre>\n\/\/ All factories should be unregistered by now\nassert(m_pFactoryList-&gt;IsEmpty());\n<\/pre>\n<p>\n&#8220;Can somebody help me figure out which factory it is that\ndid not get unregistered?&#8221;\n<\/p>\n<p>\nI didn&#8217;t work on this internal library, but on the other hand\nI&#8217;m not afraid to look inside.\n<\/p>\n<p>\nLet&#8217;s see what a <code>m_pFactory&shy;List<\/code> looks like.\n<\/p>\n<pre>\n0:000&gt; ?? this-&gt;m_pFactoryList\nclass LookupTable&lt;CFactory*&gt;\n   +0x000 <span STYLE=\"background-color: yellow\">m_uListSize      : 1<\/span> <font COLOR=\"blue\">\/\/ this probably means that the list has one element<\/font>\n   +0x004 <span STYLE=\"background-color: yellow\">m_pList          : 0x00212e60<\/span> LookupTable&lt;CFactory*&gt;::ENTRY <font COLOR=\"blue\">\/\/ this is probably the list<\/font>\n   +0x008 m_uCapacity      : 0x7f\n0:000&gt; ?? this-&gt;m_pFactoryList-&gt;m_pList\nstruct LookupTable&lt;CFactory*&gt;::ENTRY * 0x00212e60\n   +0x000 <span STYLE=\"background-color: yellow\">pszName          : 0x02cf4048<\/span>  \"GHI_factory\"\n   +0x004 <span STYLE=\"background-color: yellow\">data             : 0x02cf4ce0<\/span> CFactory* <font COLOR=\"blue\">\/\/ I bet this is the item that got leaked<\/font>\n0:000&gt; dps 0x02cf4ce0 l1\n02cf4ce0  6b626d58 GHI!CGhiFactory::`vftable`\n<\/pre>\n<p>\nNo psychic powers needed here.\nI just followed my nose.\n<\/p>\n<p>\nThe assertion says that a list is not empty.\nTherefore, we should look to see what is on the list.\n<\/p>\n<p>\nAs a general rule, code is not intentionally written to be\nimpossible to understand.\nThe person who wrote it meant well,\nso if you see a member called\n<code>m_uList&shy;Size<\/code>, it&#8217;s a pretty safe bet that it\nrepresents the list size.\nAnd if you see a member called\n<code>m_pList<\/code>,\nit probably points to the start of the list.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A programmer on the GHI team (yes, the same GHI team) reported that they were hitting an assertion failure using an internal library and asked for help debugging it. \/\/ All factories should be unregistered by now assert(m_pFactoryList-&gt;IsEmpty()); &#8220;Can somebody help me figure out which factory it is that did not get unregistered?&#8221; I didn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-1913","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A programmer on the GHI team (yes, the same GHI team) reported that they were hitting an assertion failure using an internal library and asked for help debugging it. \/\/ All factories should be unregistered by now assert(m_pFactoryList-&gt;IsEmpty()); &#8220;Can somebody help me figure out which factory it is that did not get unregistered?&#8221; I didn&#8217;t [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=1913"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1913\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=1913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=1913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=1913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}