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

Missing XMP data causes library to hang indefinitely #95

Open
ninas opened this issue Aug 29, 2024 · 2 comments
Open

Missing XMP data causes library to hang indefinitely #95

ninas opened this issue Aug 29, 2024 · 2 comments
Labels
question Further information is requested

Comments

@ninas
Copy link

ninas commented Aug 29, 2024

Hi there,
I've attached the gif I noticed this behavior on:
file.gif

I'm running this on Arch Linux, with Exiftool 12.93

This is the line that gets hung:

inputready, outputready, exceptready = select.select([fd], [], [])

Quick repro:

with exiftool.ExifToolHelper() as et:
     et.get_tags(["file.gif"], {"tags": ["ExifTool:ExifToolVersion"]})

This then hangs until manually interrupted.

When running the same using exiftool directly, it returns without issue:

$> exiftool -j -G -GIF:GIFVersion file.gif
[{
  "SourceFile": "file.gif",
  "GIF:GIFVersion": "89a"
}]

When requesting a tag that doesn't exist directly using exiftool, some warnings are printed, but otherwise everything works as expected:

$> exiftool -j -G -AllDates file.gif
Warning: [minor] Empty XMP - file.gif
[{
  "SourceFile": "file.gif"
}]

Interestingly enough, when requesting all metadata fields, rather than specific tags, then the library works as expected:

with exiftool.ExifToolHelper() as et:
     et.get_metadata(["file.gif"])

By loosely looking through the code, I could see that there's a 30 second timeout once terminate has been called. It would be great to have a general user-specified timeout option for the whole command so that this can be adjusted to match a user's usecase.

@sylikc
Copy link
Owner

sylikc commented Sep 21, 2024

Is it actually hanging at select(). Did you turn on logging to see exactly where it hangs up https://sylikc.github.io/pyexiftool/faq.html#i-m-getting-an-error-how-do-i-debug-pyexiftool-output

The terminate timeout doesn't affect Linux typically, though there was that Windows hanging bug that is still semi-fixed in Python 3.12

I'd have to set up a Linux environment to test your exact case with files... if it hangs on select, it's likely there's either something weird about the metadata in the file, or pyexiftool is trying to read an empty file descriptor, which causes the block

@sylikc sylikc added the question Further information is requested label Sep 21, 2024
@ninas
Copy link
Author

ninas commented Sep 21, 2024

This is what I get with debug logging enabled:

INFO:root:Property 'executable': set to "/usr/bin/vendor_perl/exiftool"
INFO:root:Property 'common_args': set to "['-G', '-n']"
INFO:root:Property 'config_file': set to "None"
INFO:root:Method 'execute': Command sent = [b'-ver', b'-echo4', b'=${status}=post149644']
DEBUG:root:ExifToolHelper.execute: IN  params = ('-ver',)
DEBUG:root:ExifToolHelper.execute: OUT stdout = "12.96
"
DEBUG:root:ExifToolHelper.execute: OUT stderr = ""
DEBUG:root:ExifToolHelper.execute: OUT status = 0
INFO:root:Method 'run': Exiftool version '12.96' (pid 197187) launched with args '['/usr/bin/vendor_perl/exiftool', '-stay_open', 'True', '-@', '-', '-common_args', '-G', '-n']'
INFO:root:Method 'execute': Command sent = [b'-j', b'-AllDates', b'50177829_758791611162571_747905689162088448_n_2325634544321502.gif', b'-echo4', b'=${status}=post511294']

Full repro code in case I'm using the library wrong: https://gist.github.com/ninas/79cd2fdd476d64b468145aedbf69dbc0

Using trusty print statements in the library code, I can see that it gets stuck here:

inputready, outputready, exceptready = select.select([fd], [], [])

Let me know if there's anything extra you'd like me to try. It does work fine when using exiftool directly, so I don't know that it's something fundamentally broken about the file itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants