Actions
Bug #16958
closedbytes: stack level too deep (SystemStackError)
Description
Although I can't reliably reproduce this error, it appears that SecureRandom.base64
sometimes lands in an infinite loop. Here's the stack trace in our environment:
/opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:73:in `bytes': stack level too deep (SystemStackError)
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:260:in `gen_random'
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:73:in `bytes'
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:260:in `gen_random'
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:73:in `bytes'
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:260:in `gen_random'
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:73:in `bytes'
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:260:in `gen_random'
from /opt/ui/vendor/ruby-2.7.1/lib/ruby/2.7.0/securerandom.rb:73:in `bytes'
... 10908 levels...
from /opt/ui/vendor/bundle/ruby/2.7.0/gems/mongo-2.12.1/lib/mongo/server/connection_pool/populator.rb:46:in `do_work'
from /opt/ui/vendor/bundle/ruby/2.7.0/gems/mongo-2.12.1/lib/mongo/background_thread.rb:101:in `block (2 levels) in start!'
from /opt/ui/vendor/bundle/ruby/2.7.0/gems/mongo-2.12.1/lib/mongo/background_thread.rb:99:in `catch'
from /opt/ui/vendor/bundle/ruby/2.7.0/gems/mongo-2.12.1/lib/mongo/background_thread.rb:99:in `block in start!'
SecureRandom.base64
was called from the mongo gem here:
https://github.com/mongodb/mongo-ruby-driver/blob/v2.12.1/lib/mongo/auth/scram/conversation.rb#L232
What I don't understand: from the stack trace it appears the definition of gen_random
from the base module Random::Formatter
is getting called instead of the definition from the sub module SecureRandom
, resulting in an infinite loop.
Actions
Like0
Like0Like0