From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id D82C91F9FD for ; Thu, 11 Mar 2021 11:06:38 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 15F0E120A84; Thu, 11 Mar 2021 20:05:40 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 70745120A7B for ; Thu, 11 Mar 2021 20:05:38 +0900 (JST) Received: by filterdrecv-p3iad2-fdf5ff85d-w5tlg with SMTP id filterdrecv-p3iad2-fdf5ff85d-w5tlg-18-6049F9B3-F6 2021-03-11 11:06:27.736474377 +0000 UTC m=+2549934.530832285 Received: from herokuapp.com (unknown) by ismtpd0037p1mdw1.sendgrid.net (SG) with ESMTP id Ib0rPPXuQyOSf54oubP1ZQ for ; Thu, 11 Mar 2021 11:06:27.648 +0000 (UTC) Date: Thu, 11 Mar 2021 11:06:27 +0000 (UTC) From: naruse@airemix.jp Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 78858 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 15852 X-Redmine-Issue-Author: test35965@gmail.com X-Redmine-Sender: naruse X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?UqoG4vcRhHM9V1I4f4J7DhjzUfTg+8muXbMD6UD+LVSHXtIYWyAh=2FzWQFhxzXK?= =?us-ascii?Q?K=2FCUxB6s3fCxtguZYxTXSz3thi+TUM8SZN6A3Fu?= =?us-ascii?Q?14FPgz4yEiuTnsU=2FLpM22NItOJzTKUDvcXWMEZ8?= =?us-ascii?Q?0Wn=2Fpph7hKfrF76er58r+EqQfxtoFrMDmOn6M7I?= =?us-ascii?Q?xBx3j47fk6KiNkSLPq7dgQTUvaOYWWtQjlaCAFa?= =?us-ascii?Q?tQaND+Odaop1aUapQ=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102823 Subject: [ruby-core:102823] [Ruby master Bug#15852] APPLICATION_VERIFIER_LOCKS_LOCK_IN_FREED_HEAP on exiting ruby X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15852 has been updated by naruse (Yui NARUSE). Backport changed from 2.6: REQUIRED, 2.7: REQUIRED, 3.0: REQUIRED to 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONE ruby_3_0 0074ea2d83230e10ab0cd769fff203c13d3c592f merged revision(s) 2a83650b0fd25719fb6c03bfec7bd895734d3ceb. ---------------------------------------- Bug #15852: APPLICATION_VERIFIER_LOCKS_LOCK_IN_FREED_HEAP on exiting ruby https://bugs.ruby-lang.org/issues/15852#change-90882 * Author: test35965@gmail.com (Alexander Riccio) * Status: Closed * Priority: Normal * ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32] * Backport: 2.6: REQUIRED, 2.7: REQUIRED, 3.0: DONE ---------------------------------------- Ruby appears to be freeing some critical section in ruby_vm_destruct before deleting the critical section. Critical Section objects must be deleted with DeleteCriticalSection (https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-deletecriticalsection) before freeing the owning memory. I can't tell exactly what critical section is being freed - I'm new to ruby, don't know how the VM works, and haven't built it locally - so I can't help you guys there yet. The clean stack trace is: ``` 0:000> kc # Call Site 00 vrfcore!VerifierStopMessageEx 01 vfbasics!AVrfpFreeMemLockChecks 02 vfbasics!AVrfpFreeMemNotify 03 vfbasics!AVrfpRtlFreeHeap 04 msvcrt!free 05 vfbasics!AVrfp_free 06 x64_msvcrt_ruby260!ruby_xfree 07 x64_msvcrt_ruby260!ruby_vm_destruct 08 x64_msvcrt_ruby260!ruby_cleanup 09 x64_msvcrt_ruby260!ruby_run_node 0a image00000000_00400000 0b image00000000_00400000 0c image00000000_00400000 0d KERNEL32!BaseThreadInitThunk 0e ntdll!RtlUserThreadStart ``` I'm running `C:\Ruby26-x64\bin\ruby.exe -x "C:\Ruby26-x64\bin\irb.cmd" `, with Application Verifier lock verification enabled. Application Verifier is the Windows SDK dynamic analysis tool, and it can be enabled by anybody who's installed the SDK. Add ruby.exe to the list of applications in Application Verifier and then run irb from inside windbg. Leak analysis should be enabled by default. I've attached the full debug log in Windbg. ---Files-------------------------------- ruby_freeing_active_critsec.TXT (17.2 KB) -- https://bugs.ruby-lang.org/