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 B767717DE1CF for ; Fri, 20 Feb 2015 06:50:54 +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 AE8C2B5D876 for ; Fri, 20 Feb 2015 06:54:00 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 55FB997A83A for ; Fri, 20 Feb 2015 06:54:01 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eXLTP0q4McHx for ; Fri, 20 Feb 2015 06:54:01 +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 19FF897A826 for ; Fri, 20 Feb 2015 06:54:01 +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 A5D94952408 for ; Fri, 20 Feb 2015 06:53:59 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6FBC4120433; Fri, 20 Feb 2015 06:53:56 +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 A134F120410 for ; Fri, 20 Feb 2015 06:53:29 +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=zTwjQbtAmFAr/k+lZYVdRS4m8oM=; b=dcBmbQTvu3rK036sdG fSkQ5a4JKM6YyVZkhLxs11Pxxdag6SjSyEJGT2mGfdmqHppJHp14kbFfbxwPULRH d1n241OaZPTqJbkv43bqAvgs9ktunFLNhBYuDuYm0GOiHCoPC+E7oXup/3rPksm8 bu2xLyUzrMr0jEDFMx9WfC49I= Received: by filter0248p1mdw1.sendgrid.net with SMTP id filter0248p1mdw1.4061.54E65B5224 2015-02-19 21:53:23.587685159 +0000 UTC Received: from herokuapp.com (ec2-54-221-39-232.compute-1.amazonaws.com [54.221.39.232]) by ismtpd-022 (SG) with ESMTP id 14ba3d4be3a.2d99.4e4573 for ; Thu, 19 Feb 2015 21:53:23 +0000 (UTC) Date: Thu, 19 Feb 2015 21:53:23 +0000 From: evan@phx.io 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: 42619 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10871 X-Redmine-Issue-Author: evanphx X-Redmine-Sender: evanphx X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: OOF Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS5IJwmdtY6DGktwVemH2QOmvqQs4TTXQZs+lD 3PN6lVeTrPMp8foaEXZ3KGY7UAfVr4UKbUvIifPLp2X6mJhlii1oAnHYJrazlQXhz5lZ46+Ji/r7pm iKLIiHTpIk+QqhVwlPbj9+AlkvT+OHUAISoB X-ML-Name: ruby-core X-Mail-Count: 68191 Subject: [ruby-core:68191] [Ruby trunk - Bug #10871] [Open] 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 reported by Evan Phoenix. ---------------------------------------- Bug #10871: Sclass thread unsafe due to CREF sharing https://bugs.ruby-lang.org/issues/10871 * Author: Evan Phoenix * Status: Open * Priority: High * Assignee: * ruby -v: 2.2.0p0, trunk * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- 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/