[前][次][番号順一覧][スレッド一覧]

ruby-changes:58724

From: Koichi <ko1@a...>
Date: Tue, 12 Nov 2019 04:35:10 +0900 (JST)
Subject: [ruby-changes:58724] b8d242d221 (master): release RUBYGEMS_ACTIVATION_MONITOR correctly.

https://git.ruby-lang.org/ruby.git/commit/?id=b8d242d221

From b8d242d221641752a495ca43f8f211a3ad73d467 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Tue, 12 Nov 2019 04:33:28 +0900
Subject: release RUBYGEMS_ACTIVATION_MONITOR correctly.

`File.symlink? safe_lp` can raise SecurityError and raising an
exception can leave RUBYGEMS_ACTIVATION_MONITOR locking. This
patch release it correctly.

diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 88b1bd9..944bb93 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -42,7 +42,15 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_require.rb#L42
       rp = nil
       $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
         safe_lp = lp.dup.tap(&Gem::UNTAINT)
-        next if File.symlink? safe_lp # for backword compatibility
+        begin
+          if File.symlink? safe_lp # for backword compatibility
+            next
+          end
+        rescue SecurityError
+          RUBYGEMS_ACTIVATION_MONITOR.exit
+          raise
+        end
+
         Gem.suffixes.each do |s|
           full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
           if File.file?(full_path)
@@ -159,7 +167,7 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_require.rb#L167
     raise load_error
   ensure
     if RUBYGEMS_ACTIVATION_MONITOR.mon_owned?
-      STDERR.puts [$!, $!.backtrace].inspect
+      STDERR.puts [$$, Thread.current, $!, $!.backtrace].inspect if $!
       raise "CRITICAL: RUBYGEMS_ACTIVATION_MONITOR is holding."
     end
   end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]