{"id":29703,"date":"2006-09-18T10:00:01","date_gmt":"2006-09-18T10:00:01","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2006\/09\/18\/sometimes-my-psychic-powers-are-weak\/"},"modified":"2006-09-18T10:00:01","modified_gmt":"2006-09-18T10:00:01","slug":"sometimes-my-psychic-powers-are-weak","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20060918-01\/?p=29703","title":{"rendered":"Sometimes my psychic powers are weak"},"content":{"rendered":"<blockquote CLASS=\"q\">\n<p>\nWhy does my MFC program exit unexpectedly?\nThe stack trace at the point we hit <code>ExitInstance<\/code>\ngoes like this:\n<\/p>\n<pre>\nCClientConsoleApp::ExitInstance\nCWinThread::Run+0x88\nAfxWinMain+0x84\n_wWinMainCRTStartup+0x138\nBaseThreadInitThunk+0xe\n_RtlUserThreadStart+0x23\n<\/pre>\n<p>\nThanks.\n<\/p>\n<\/blockquote>\n<p>\nYou can already see some of what&#8217;s going on, but clearly\nmore information is needed.\nMy first psychic suggestion was to examine MFC&#8217;s message\npump to see what causes it to exit.\nThen follow the money backwards.\n<\/p>\n<blockquote CLASS=\"q\"><p>\nThat&#8217;s what we want to know and what we want to find out.\n<\/p><\/blockquote>\n<p>\nMFC comes with source code so you can do this yourself.\nDon&#8217;t expect somebody to do your debugging for you.\nYou have the tools to do it yourself:\nYou have the source code and you have a brain.\n<\/p>\n<p>\nOnce you figure out what conditions make MFC&#8217;s message pump exit,\nthen try to figure out which of those conditions is actually\noccurring, and then set breakpoints to try to catch the\ncondition being achieved.\n<\/p>\n<p>\nI don&#8217;t have the MFC source code memorized and I didn&#8217;t feel\nlike installing it just to help somebody solve their own problem,\nso I resorted to wild guessing in the guise of psychic powers:\n<\/p>\n<blockquote CLASS=\"q\"><p>\nI don&#8217;t know what MFC&#8217;s message pump looks like\nbut my psychic powers tell me that it stops when it gets a\n<code>WM_QUIT<\/code> message.\nMy psychic powers are losing strength\nfrom being so heavily stressed so early in the morning&#8230;\nI see a shadow, a vague form,\nit&#8217;s not all that clear, kind of hazy,\nit might be&#8230; yes I think it says\n&#8220;<code>PostQuitMessage<\/code>&#8220;&#8230;\nhard to tell&#8230; connection fading&#8230;\n<\/p><\/blockquote>\n<p>\n(Sorry, I can&#8217;t finish up this story with a snappy ending.\nIt happened so long ago I forget what the problem was.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why does my MFC program exit unexpectedly? The stack trace at the point we hit ExitInstance goes like this: CClientConsoleApp::ExitInstance CWinThread::Run+0x88 AfxWinMain+0x84 _wWinMainCRTStartup+0x138 BaseThreadInitThunk+0xe _RtlUserThreadStart+0x23 Thanks. You can already see some of what&#8217;s going on, but clearly more information is needed. My first psychic suggestion was to examine MFC&#8217;s message pump to see what causes [&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":[26],"class_list":["post-29703","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Why does my MFC program exit unexpectedly? The stack trace at the point we hit ExitInstance goes like this: CClientConsoleApp::ExitInstance CWinThread::Run+0x88 AfxWinMain+0x84 _wWinMainCRTStartup+0x138 BaseThreadInitThunk+0xe _RtlUserThreadStart+0x23 Thanks. You can already see some of what&#8217;s going on, but clearly more information is needed. My first psychic suggestion was to examine MFC&#8217;s message pump to see what causes [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/29703","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=29703"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/29703\/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=29703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=29703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=29703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}