-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy load Digest::SHA256 is not thread safe #1279
Comments
I'm seeing this too on my project... NotImplementedError: the Digest::SHA256() function is unimplemented on this machine |
Solved via: require 'digest' :-) |
Still an issue, but appears to be differently broken:
The following patch fixes it but I have no investigated whether there's a bug (e.g. in our locking multi-thread require) we should fix. diff --git a/lib/ruby/stdlib/digest.rb b/lib/ruby/stdlib/digest.rb
index d6daf36..2625f31 100644
--- a/lib/ruby/stdlib/digest.rb
+++ b/lib/ruby/stdlib/digest.rb
@@ -6,22 +6,24 @@ module Digest
REQUIRE_MUTEX = Mutex.new
def self.const_missing(name) # :nodoc:
- case name
- when :SHA256, :SHA384, :SHA512
- lib = 'digest/sha2.so'
- else
- lib = File.join('digest', name.to_s.downcase)
- end
+ Digest::REQUIRE_MUTEX.synchronize do
+ case name
+ when :SHA256, :SHA384, :SHA512
+ lib = 'digest/sha2.so'
+ else
+ lib = File.join('digest', name.to_s.downcase)
+ end
- begin
- require lib
- rescue LoadError
- raise LoadError, "library not found for class Digest::#{name} -- #{lib}", caller(1)
- end
- unless Digest.const_defined?(name)
- raise NameError, "uninitialized constant Digest::#{name}", caller(1)
+ begin
+ require lib
+ rescue LoadError
+ raise LoadError, "library not found for class Digest::#{name} -- #{lib}", caller(1)
+ end
+ unless Digest.const_defined?(name)
+ raise NameError, "uninitialized constant Digest::#{name}", caller(1)
+ end
+ Digest.const_get(name)
end
- Digest.const_get(name)
end
class ::Digest::Class |
Fixed for 9k and 1.7. |
This is motivated by a rare error which was fixed in 9.1.3. Some more context in this issue: jruby/jruby#1279
This is motivated by a rare error which was fixed in 9.1.3. Some more context in this issue: jruby/jruby#1279
Incredibly weird - I just saw this when building a Docker image. Here is the backtrace: Backtrace
Environment
The Dockerfile has this
I can very well create a new GitHub issue for this if you like, but it feels like it's the original problem coming back somehow... so we could as well reopen this one. |
(I only saw this one single time. Subsequent times it has worked flawlessly.) |
Hi,
Recently we observed that our production log has load error for Digest::SHA256 resulting in,
NotImplementedError: the Digest::SHA256() function is unimplemented on this machine
This is reproducible on master with the following change,
on 413f5dd, at line 228 of RubyDigest, insert snippet,
I have attached an image of the RubyDigest with sleep code.
Thanks,
Vinay.
The text was updated successfully, but these errors were encountered: