{"id":1173,"date":"2008-02-12T15:19:02","date_gmt":"2008-02-12T15:19:02","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2008\/02\/12\/debugging-custom-actions-leaked-handles\/"},"modified":"2019-02-17T15:30:05","modified_gmt":"2019-02-17T22:30:05","slug":"debugging-custom-actions-leaked-handles","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/debugging-custom-actions-leaked-handles\/","title":{"rendered":"Debugging Custom Actions: Leaked Handles"},"content":{"rendered":"<p><a href=\"http:\/\/msdn2.microsoft.com\/library\/aa368264.aspx\">Debugging custom actions<\/a> isn&#8217;t exactly the easiest action to do; Windows Installer spawns separate processes &#8211; remoting servers &#8211; to run in-process custom actions. Any opportunity to diagnose issues without debugging can be helpful.<\/p>\n<p>For example, an issue that comes up from time to time is leaked handles. A Windows Installer debug log might show something similar to the following:<\/p>\n<p><code>MSI (s) (CC:1C) [17:40:29:055]: Doing action: MyCustomAction<br \/>MSI (s) (CC:58) [17:40:29:165]: Invoking remote custom action. DLL: C:WINDOWSInstallerMSI1B.tmp, Entrypoint: MyCustomAction<br \/>Action start 17:40:29: MyCustomAction.<br \/>MSI (s) (CC:58) [17:40:29:906]: <span class=\"highligh\" style=\"background-color: yellow\">Leaked MSIHANDLE (219) of type 790531<\/span> for thread 3676<br \/>MSI (s) (CC:58) [17:40:29:906]: <span class=\"highligh\" style=\"background-color: yellow\">Leaked MSIHANDLE (190) of type 790540<\/span> for thread 3676<br \/>MSI (s) (CC:58) [17:40:29:906]: <span class=\"highligh\" style=\"background-color: yellow\">Leaked MSIHANDLE (189) of type 790540<\/span> for thread 3676<br \/>MSI (s) (CC:58) [17:40:29:906]: <span class=\"highligh\" style=\"background-color: yellow\">Leaked MSIHANDLE (188) of type 790540<\/span> for thread 3676<br \/>MSI (s) (CC:58) [17:40:29:906]: <span class=\"highligh\" style=\"background-color: yellow\">Leaked MSIHANDLE (179) of type 790541<\/span> for thread 3676<br \/>MSI (s) (CC:58) [17:40:29:906]: Note: 1: 2769 2: MyCustomAction 3: 5 <br \/>DEBUG: Error 2769: Custom Action MyCustomAction did not close 5 <br \/>Action ended 17:40:30: MyCustomAction. Return value 3.<\/code><\/p>\n<p>Windows Installer provides a clue in the log that can help with a code review. The Windows Installer team has provided the following information:<\/p>\n<ul>\n<li>MSIHANDLE type 790531 identifies a record  <\/li>\n<li>MSIHANDLE type 790540 identifies a view  <\/li>\n<li>MSIHANDLE type 790541 identifies a database<\/li>\n<\/ul>\n<p>With this knowledge, you should be able to review your code and spot cause of the issue.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Debugging custom actions isn&#8217;t exactly the easiest action to do; Windows Installer spawns separate processes &#8211; remoting servers &#8211; to run in-process custom actions. Any opportunity to diagnose issues without debugging can be helpful. For example, an issue that comes up from time to time is leaked handles. A Windows Installer debug log might show [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[10,12,15,20,23],"class_list":["post-1173","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-custom-actions","tag-debugging","tag-diagnosing","tag-installation","tag-logging"],"acf":[],"blog_post_summary":"<p>Debugging custom actions isn&#8217;t exactly the easiest action to do; Windows Installer spawns separate processes &#8211; remoting servers &#8211; to run in-process custom actions. Any opportunity to diagnose issues without debugging can be helpful. For example, an issue that comes up from time to time is leaked handles. A Windows Installer debug log might show [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/1173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=1173"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/1173\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=1173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=1173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=1173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}