From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 1EBA919A02A1 for ; Tue, 25 Aug 2015 00:49:40 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 41D16B5D869 for ; Tue, 25 Aug 2015 01:26:56 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 46E3297A826 for ; Tue, 25 Aug 2015 01:26:57 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 2FADE952439 for ; Tue, 25 Aug 2015 01:26:53 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id ECEB612046A; Tue, 25 Aug 2015 01:26:52 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id A0F4C120462 for ; Tue, 25 Aug 2015 01:26:49 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=Pv4y5IMkNy5Zjp2jM7Ry7xQ6Uaw=; b=lgIyZCd8xDJihMaPcV SJkVrQu10W95LjsbQvtu25NU+f46nULDS35FETAgCPjvseZqHshdfYUofDK4gFdh 9/bKjy8Ihy0NFOZVRl4jTnnl1AEZoBFH1iFLY1xpTyv6YPhGfQbKxbM/cyD3DMgf q6+6WmSYBGWQSqR6HocMv6Srg= Received: by filter0635p1mdw1.sendgrid.net with SMTP id filter0635p1mdw1.8514.55DB45C424 2015-08-24 16:26:44.787573423 +0000 UTC Received: from herokuapp.com (ec2-54-227-57-102.compute-1.amazonaws.com [54.227.57.102]) by ismtpd0003p1iad1.sendgrid.net (SG) with ESMTP id EgCQ5g_UTG2qI4znoHe0OA Mon, 24 Aug 2015 16:26:44.598 +0000 (UTC) Date: Mon, 24 Aug 2015 16:26:44 +0000 From: nagachika00@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 45187 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10871 X-Redmine-Issue-Author: evanphx X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: nagachika 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS73U0JbNF54iiyvkfXYN6Um8198D6n5s8HaZN 0DEz+t9tsFOyMPVQMvk7POYuNfAuT7cgORM/6mVwcT9fkdwaS4Le4B8CvmBDgCnEnCbGvwobDQM2xW tOmQ4LSToKQgX+uNtvRb8Uhk0tboOemW6OVj X-ML-Name: ruby-core X-Mail-Count: 70574 Subject: [ruby-core:70574] [Ruby trunk - Bug #10871] Sclass thread unsafe due to CREF sharing 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #10871 has been updated by Tomoyuki Chikanaga. Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: DONE Hello, I've applied ko1's workaround patch for this issue to `ruby_2_2` branch at r51673. I'm worried about the wrong side effects of this patch. Please test on `ruby_2_2` branch HEAD. If you use rbenv/ruby-build, you can install `ruby_2_2` HEAD via rbenv install 2.2.0-dev Regards, ---------------------------------------- Bug #10871: Sclass thread unsafe due to CREF sharing https://bugs.ruby-lang.org/issues/10871#change-53982 * Author: Evan Phoenix * Status: Closed * Priority: Normal * Assignee: Koichi Sasada * ruby -v: 2.2.0p0, trunk * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: DONE ---------------------------------------- When entering an sclass, the context is tracked via the same cref mechanism used for class and module, specifically on the iseq->cref_stack. The bug is that the cref_stack is the wrong place to put the new cref because the scope is specific only to that sclass body. Mutating and using the iseq->cref_stack causes any code that reads the cref via this cref_stack to incorrectly pick up the sclass instance instead of the proper scope! This is major thread safety bug because it means that all uses of `class << obj` are thread-unsafe and can cause random code to fail. Here is a simple reproduction of the bug: https://gist.github.com/evanphx/6eef92f2c40662a4171b I attempted to fix the bug by treating an sclass body the same as an eval, which already has special handling for cref's but I don't understand the code enough to make that change quickly. I believe this is a major bug and hope that ruby-core can address it soon. Thank you! -- https://bugs.ruby-lang.org/