Skip to content

Problem with Popen arguments passed as map #436

Description

@lorinkoz

Greetings!

I am having an issue when using the package sorl.thumbnail on a Django project. That package produces thumbnails from images using system installed programs (called engines.)

When sorl.thumbnail makes a Popen call here:

https://github.com/jazzband/sorl-thumbnail/blob/22ccd9781462a820f963f57018ad3dcef85053ed/sorl/thumbnail/engines/convert_engine.py#L57

The arguments that are received in your patched Popen are not being interpreted correctly. This is the suspect of the problem:

def sentry_patched_popen_init(self, *a, **kw):

Arguments are handled in such a way that the original popen crashes when trying to access args[0], as the args parameter is interpreted (or actually becomes) an empty list.

In my opinion, the problem arises because in sorl.thumbnail the arguments to Popen are passed to a map function first, so that a map object is what gets passed as arguments. I am not sure what's the effect of a map object being received in your *a of the patched Popen.

Here's the relevant part of the traceback I am getting:

File "/mnt/d/Proyectos/ginseng/.venv/lib/python3.6/site-packages/sorl/thumbnail/base.py", line 131, in get_thumbnail
    thumbnail)
  File "/mnt/d/Proyectos/ginseng/.venv/lib/python3.6/site-packages/sorl/thumbnail/base.py", line 164, in _create_thumbnail
    default.engine.write(image, options, thumbnail)
  File "/mnt/d/Proyectos/ginseng/.venv/lib/python3.6/site-packages/sorl/thumbnail/engines/convert_engine.py", line 57, in write
    p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/mnt/d/Proyectos/ginseng/.venv/lib/python3.6/site-packages/sentry_sdk/integrations/stdlib.py", line 165, in sentry_patched_popen_init
    return old_popen_init(self, *a, **kw)
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1248, in _execute_child
    executable = args[0]
IndexError: list index out of range

If I remove the Sentry integration altogether from the Django project, sorl.thumbnail is able to effectively call Popen with the "mapped" arguments, and everything works.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions