From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS43350 77.247.176.0/21 X-Spam-Status: No, score=-0.7 required=3.0 tests=AWL,BAYES_00,MSGID_RANDY, RCVD_IN_XBL shortcircuit=no autolearn=no version=3.3.2 X-Original-To: spew@80x24.org Received: from 80x24.org (chomsky.torservers.net [77.247.181.162]) by dcvr.yhbt.net (Postfix) with ESMTP id 005FE1FA70 for ; Thu, 1 Jan 2015 01:48:34 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] symbol.c: fix memory leak from global fstr hash Date: Thu, 1 Jan 2015 01:48:33 +0000 Message-Id: X-Mailer: git-send-email 2.2.0 List-Id: * symbol.c (rb_gc_free_dsymbol): delete from global fstr hash * test/ruby/test_symbol.rb (test_symbol_fstr_leak) [ruby-core:67268] [Bug #10686] --- symbol.c | 1 + test/ruby/test_symbol.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/symbol.c b/symbol.c index f067ebe..1127020 100644 --- a/symbol.c +++ b/symbol.c @@ -664,6 +664,7 @@ rb_gc_free_dsymbol(VALUE sym) if (str) { RSYMBOL(sym)->fstr = 0; unregister_sym(str, sym); + rb_hash_delete_entry(global_symbols.dsymbol_fstr_hash, str); } } diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index a25e6fb..e2f9bfb 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -230,4 +230,12 @@ class TestSymbol < Test::Unit::TestCase end assert_nothing_raised(NoMethodError, bug10259) {obj.send("unagi=".intern, 1)} end + + def test_symbol_fstr_leak + bug10686 = '[ruby-core:67268] [Bug #10686]' + x = 0 + assert_no_memory_leak([], '', <<-"end;", bug10686) + 200_000.times { |i| i.to_s.to_sym } + end; + end end -- EW