{"id":22023,"date":"2008-06-09T10:00:00","date_gmt":"2008-06-09T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2008\/06\/09\/why-are-dlls-uninitialized-in-the-wrong-order\/"},"modified":"2008-06-09T10:00:00","modified_gmt":"2008-06-09T10:00:00","slug":"why-are-dlls-uninitialized-in-the-wrong-order","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20080609-00\/?p=22023","title":{"rendered":"Why are DLLs uninitialized in the &#034;wrong&#034; order?"},"content":{"rendered":"<p> This is really just a corollary to <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/05\/23\/421024.aspx\"> Why are DLLs unloaded in the &#8220;wrong&#8221; order<\/a>. Exactly the same logic that explains why DLLs are unloaded in the &#8220;wrong&#8221; order also explains why they are uninitialized in the &#8220;wrong&#8221; order. Once you understand the first issue, the second comes for free; just change <code>DLL_PROCESS_DETACH<\/code> to <code>DLL_THREAD_DETACH<\/code> in your analysis. <\/p>\n<p> Apply the logic to <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/05\/23\/421024.aspx#422023\"> the scenario posed in this comment<\/a> and you&#8217;ll see why it too is flawed. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is really just a corollary to Why are DLLs unloaded in the &#8220;wrong&#8221; order. Exactly the same logic that explains why DLLs are unloaded in the &#8220;wrong&#8221; order also explains why they are uninitialized in the &#8220;wrong&#8221; order. Once you understand the first issue, the second comes for free; just change DLL_PROCESS_DETACH to DLL_THREAD_DETACH [&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-22023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>This is really just a corollary to Why are DLLs unloaded in the &#8220;wrong&#8221; order. Exactly the same logic that explains why DLLs are unloaded in the &#8220;wrong&#8221; order also explains why they are uninitialized in the &#8220;wrong&#8221; order. Once you understand the first issue, the second comes for free; just change DLL_PROCESS_DETACH to DLL_THREAD_DETACH [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/22023","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=22023"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/22023\/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=22023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=22023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=22023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}