ueno/ruby-gpgme

Errno::ENOMEM Foked process memory issue?

Opened this issue · 0 comments

We are using this on a big site, server has 32 Gb ram. But after a couple of days runing we are receiving this error when trying to encript a binary file:

Errno::ENOMEM (Cannot allocate memory):
  gpgme (2.0.2) lib/gpgme/ctx.rb:219:in `keylist_start'
  gpgme (2.0.2) lib/gpgme/ctx.rb:250:in `each_key'
  gpgme (2.0.2) lib/gpgme/ctx.rb:265:in `keys'
  gpgme (2.0.2) lib/gpgme/key.rb:57:in `find'
  gpgme (2.0.2) lib/gpgme/ctx.rb:67:in `new'
  gpgme (2.0.2) lib/gpgme/key.rb:56:in `find'
  gpgme (2.0.2) lib/gpgme/key.rb:52:in `each'
  gpgme (2.0.2) lib/gpgme/key.rb:52:in `find'
  gpgme (2.0.2) lib/gpgme/crypto.rb:84:in `encrypt'
  lib/attachment_auto_backup.rb:13:in `send_to_s3'
  app/models/zipped_file.rb:19
....
  config/initializers/mongrel.rb:62:in `dispatch_cgi'

this is our code:

crypto = GPGME::Crypto.new
    crypted_content = crypto.encrypt relative_path_tarball, :recipients => "our@email.com", :always_trust => true

My experience suggest me that this is because an attemp to fork a process... but I've searched over the gpgme code and it seems to happend on a loop trying to find the key to encrypt.

crypto.rb
keys        = Key.find(:public, options[:recipients])

If i run on rails console:

GPGME::Key.find :public, "our@email.com"

I got this output almost inmediatly:

[
    [0] #<GPGME::Key pub 1024D/9869EFC4 2007-11-17 trust=nil, owner_trust=:ultimate, capability=[:encrypt, :sign, :certify, :authenticate], subkeys=[#<GPGME::SubKey sub 1024D/XXXXX XXX-11-17 trust=nil, capability=[:encrypt, :sign, :certify, :authenticate]>, #<GPGME::SubKey sub 2048g/XXXXXXXX 2007-11-17 trust=nil, capability=[:encrypt, :sign, :certify, :authenticate]>], uids=[#<GPGME::UserID XXX <our@email.com> validity=ultimate, signatures=[]>]>
]