Skip to content

Lazy load Digest::SHA256 is not thread safe #1279

@vinayshastry

Description

@vinayshastry

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,

  1. Add sleep into RubyDigest so that it takes a while to assign metadata,
    on 413f5dd, at line 228 of RubyDigest, insert snippet,
try {
            System.out.println("sleep 10 seonds before instance v set");
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
  1. Run the following ruby script,
require 'digest'
threads = []
100.times do
  threads << (Thread.new do
    begin
      Digest::SHA256.new
    rescue Exception => e
      puts "[DEBUG]e => #{e.inspect}"
    end
  end)
end
threads.each(&:join)

I have attached an image of the RubyDigest with sleep code.

screen shot 2013-11-27 at 2 15 59 pm

Thanks,
Vinay.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions