Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot allocate memory issue #252

Open
mandarGG opened this issue Feb 18, 2025 · 1 comment
Open

Cannot allocate memory issue #252

mandarGG opened this issue Feb 18, 2025 · 1 comment
Labels
pending Issue will be closed if feedback not received soon.

Comments

@mandarGG
Copy link

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

To Reproduce
Steps to reproduce the behavior:
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()

Expected behavior
File should get decrypted successfully

Screenshots
Do not have screenshot but exact error is this
\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

Additional information
Apologies in advance if any information is sufficient as I am not very used to raising issues , however I saw here that using the option --auto-expand-secmem has solved the issue for lot of people facing the issue. 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

  1. How can I use this option in the gnupg package
  2. Is there a way to limit the max memory being used via this option since in the worst I want to avoid this consuming the majority of system's RAM
@vsajip vsajip added the pending Issue will be closed if feedback not received soon. label Feb 19, 2025
@vsajip
Copy link
Owner

vsajip commented Feb 19, 2025

Well, how much free memory do you have before running your program? Are you running into problems on your own machine, or a VPS or container somewhere?

The --auto-expand-secmem appears to be a parameter passed to gpg-agent, not gpg, so I'm not sure it'll help you from pytho-gnupg. Did you read the documentation for decrypt_file() carefully? If you did, how is it you "could not see anything mentioned" about passing other arguments?

Does the test suite test_gnupg.py run on the machine in question? You can turn on logging for gnupg and the log will show the exact command lines used to invoke gpg. What happens if you call gpg directly from the command line with the same or equivalent arguments?

In general people haven't reported memory-related problems, and the error you showed is from gpg and not due to python-gnupg. It sounds like it's related to low memory in your environment. I'll mark this as pending and close it soon if I don't see some evidence that the problem is due to python-gnupg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending Issue will be closed if feedback not received soon.
Projects
None yet
Development

No branches or pull requests

2 participants