Issue #14716 has been updated by michalsamluk (Micha Samluk).

ruby -v changed from 2.5.3 to 2.6.3

Hi,
I am having same issue while running seed data (ruby 2.6.3). I am having it while uplaoding attachments. 

```
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/core_ext/securerandom.rb:39:in `base36'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activestorage-6.0.0.rc2/app/models/active_storage/blob.rb:89:in `generate_unique_secure_token'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/secure_token.rb:32:in `block in has_secure_token'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:429:in `instance_exec'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:429:in `block in make_lambda'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:201:in `block (2 levels) in halting'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:607:in `block (2 levels) in default_terminator'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:606:in `catch'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:606:in `block in default_terminator'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:202:in `block in halting'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:514:in `block in invoke_before'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:514:in `each'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:514:in `invoke_before'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:134:in `run_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:827:in `_run_create_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/callbacks.rb:332:in `_create_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/timestamp.rb:111:in `_create_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/persistence.rb:906:in `create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/callbacks.rb:328:in `block in create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:135:in `run_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/callbacks.rb:328:in `create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/timestamp.rb:129:in `create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/persistence.rb:470:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/validations.rb:46:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:315:in `block in save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:275:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:212:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:315:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/suppressor.rb:44:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/autosave_association.rb:489:in `save_belongs_to_association'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/autosave_association.rb:204:in `block in add_autosave_association_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/autosave_association.rb:159:in `instance_eval'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/autosave_association.rb:159:in `block in define_non_cyclic_method'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:429:in `block in make_lambda'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:201:in `block (2 levels) in halting'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:607:in `block (2 levels) in default_terminator'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:606:in `catch'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:606:in `block in default_terminator'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:202:in `block in halting'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:514:in `block in invoke_before'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:514:in `each'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:514:in `invoke_before'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:134:in `run_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/callbacks.rb:328:in `create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/timestamp.rb:129:in `create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/persistence.rb:470:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/validations.rb:46:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:315:in `block in save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:275:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:212:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:315:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/suppressor.rb:44:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/has_one_association.rb:58:in `block in replace'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/has_one_association.rb:103:in `block in transaction_if'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:275:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:212:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/has_one_association.rb:103:in `transaction_if'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/has_one_association.rb:51:in `replace'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/singular_association.rb:17:in `writer'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/builder/association.rb:108:in `media_attachment='
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activestorage-6.0.0.rc2/lib/active_storage/attached/changes/create_one.rb:32:in `public_send'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activestorage-6.0.0.rc2/lib/active_storage/attached/changes/create_one.rb:32:in `save'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activestorage-6.0.0.rc2/lib/active_storage/attached/model.rb:54:in `block in has_one_attached'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:429:in `instance_exec'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:429:in `block in make_lambda'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:239:in `block in halting_and_conditional'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:518:in `block in invoke_after'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:518:in `each'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:518:in `invoke_after'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:136:in `run_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.0.rc2/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/callbacks.rb:328:in `create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/timestamp.rb:129:in `create_or_update'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/persistence.rb:503:in `save!'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/validations.rb:52:in `save!'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:319:in `block in save!'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:275:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:212:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:319:in `save!'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/suppressor.rb:48:in `save!'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:360:in `insert_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/has_many_association.rb:36:in `insert_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:347:in `block (2 levels) in _create_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:443:in `replace_on_target'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:285:in `add_to_target'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:346:in `block in _create_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:135:in `block in transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:277:in `block in transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:277:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/transactions.rb:212:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:134:in `transaction'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_association.rb:344:in `_create_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/has_many_association.rb:116:in `_create_record'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/association.rb:195:in `create!'
/Users/myuser/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.0.rc2/lib/active_record/associations/collection_proxy.rb:363:in `create!'
```

----------------------------------------
Bug #14716: SecureRandom throwing an error in Ruby 2.5.1
https://bugs.ruby-lang.org/issues/14716#change-80873

* Author: snehavas (sneha vasanth)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.3
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED
----------------------------------------
Hi,

We recently upgraded from ruby 2.3.6 to 2.5.1.
We use SecureRandom.uuid to generate a random number for our session.
Post the upgrade we have been getting the following error intermittently

```
app error: failed to get urandom (RuntimeError)
E, [2018-04-27T04:55:08.741859 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:99:in `urandom'
E, [2018-04-27T04:55:08.741898 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:99:in `gen_random_urandom'
E, [2018-04-27T04:55:08.741932 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:129:in `random_bytes'
E, [2018-04-27T04:55:08.741965 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:219:in `uuid'
E, [2018-04-27T04:55:08.741997 #16550] ERROR -- : /usr/share/nginx/frontend/app/utilities/log.rb:74:in `create_session_info'
E, [2018-04-27T04:55:08.742036 #16550] ERROR -- : /usr/share/nginx/frontend/app/utilities/log.rb:11:in `context'
```

We understand that there was a change in ruby 2.5.1 where we now look at OS sources as the first point of contact to generate random numbers as opposed to OpenSSL.
Any idea why this could be happening?







-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>