0

Intermittently getting cannot allocate memory error while decrypting a file via python gnupg package

To Reproduce

Initialize the gpg agent and decrypt the file : gpg_obj = gnupg.GPG(gnupghome=os.path.expanduser('~')) gpg_obj.encoding = 'utf-8' gpg_obj.decrypt_file()

Exact Error

\ngpg: public key decryption failed: Cannot allocate memory\n[GNUPG:] ERROR pkdecrypt_failed 67141718\n[GNUPG:] BEGIN_DECRYPTION\n[GNUPG:] DECRYPTION_FAILED\ngpg: decryption failed: No secret key\n[GNUPG:] END_DECRYPTION\n

Environment

OS, including version : Ubuntu 20.04.6 LTS Version of this library: python-gnupg==0.5.0 Version of GnuPG: gpg (GnuPG) 2.2.19, libgcrypt 1.8.5 Note : Sufficient RAM is available (around 14/32GB is available) when this issue occurrs

Saw here that using the option --auto-expand-secmem has solved the issue for lot of people. However I could not see anything mentioned about how to use this option via the python gnupg package. And I am facing a critical issue regarding this. It would be great if I can get help reg:

  • How can I use this option in the gnupg package
  • Is there a way to limit the max memory being used via this option since in the worst case I want to avoid this consuming the majority of system's RAM

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.