NotImplementedError in XMP reading cause segfault

Bug #683528 reported by VinsS
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Committed
High
Olivier Tilloy

Bug Description

NotImplementedError in XMP reading cause a crash of my application
with segfault if reading XMP value is directly into a try-except clause.

the code is trivial :

obj = pyexiv2.ImageMetadata(image)
obj.read()
...
xk = obj.xmp_keys

    for k in xk:
        try:
            xmp[k] = obj[k].value
        except:
            pass
else :
    xmp = False

>>> Erreur de segmentation

if I try :

    for k in xk:
        print k, obj[k].value
        try:
            xmp[k] = obj[k].value
        except:
            pass

>>>
  ...
  File "oqapy.py", line 2806, in read_infos
    self.datas_list = self.meta.read_metadatas(im)
  File "/home/vincent/Python/oqapy/devel/oqapy-0.4.0/Ometadata.py", line 116, in read_metadatas
    print k, obj[k].value
  File "/usr/lib/pymodules/python2.6/pyexiv2/xmp.py", line 208, in _get_value
    self._compute_value()
  File "/usr/lib/pymodules/python2.6/pyexiv2/xmp.py", line 202, in _compute_value
    self._value = self._convert_to_python(self._raw_value, self.type)
  File "/usr/lib/pymodules/python2.6/pyexiv2/xmp.py", line 366, in _convert_to_python
    raise NotImplementedError('XMP conversion for type [%s]' % type)
NotImplementedError: XMP conversion for type [Flash]

Without the line print and with gdb :

$ gdb python
(gdb) set args oqapy.py
(gdb) run
Starting program: /usr/bin/python oqapy.py
[Thread debugging using libthread_db enabled]
Pyexiv version : (0, 2, 2)

Program received signal SIGSEGV, Segmentation fault.
0x0096b4a5 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) ()
   from /usr/lib/libstdc++.so.6

But, if I insert the loop enterely in the clause try-except :

try:
    for k in xk:
        xmp[k] = obj[k].value
except:
    pass

That's work !
Ok, the following XMP are lost, but no crash

Ubuntu 10.04 + 10.10
python 2.6
pyexiv 0.2.2

Tags: xmp
Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the report Vincent.
Could you please attach an image that causes the issue? I’m curious to see what this "Flash" type is for XMP tags, I’ve never seen it before.

The indentation in your first example seems to be incorrect, and I don’t quite understand the else clause, but the try…except block should definitely catch the exception.

Revision history for this message
VinsS (vincent-vandevyvre) wrote :

Hi Olivier,

For the indentation, I forgot one line :

     xk = obj.xmp_keys
+ if xk:
         for k in xk:
            try:
                xmp[k] = obj[k].value
            except:
                pass
    else :
        xmp = False

I join an image.

Revision history for this message
Olivier Tilloy (osomon) wrote :

That’s interesting, I can’t reproduce the segmentation fault with pyexiv2’s trunk (soon to be 0.3).
I’ll test with 0.2.2.

Revision history for this message
Olivier Tilloy (osomon) wrote :

And indeed I can reproduce with 0.2.2.
This means the issue was fixed since then, likely by the patch for bug #622739.

Olivier Tilloy (osomon)
Changed in pyexiv2:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Olivier Tilloy (osomon) wrote :

I bisected the revisions since 0.2.2 and it turns out that the commit that fixes the issue is revision 330 (bug #677267).

The tag that triggered this segmentation fault in the attached image is "Xmp.crs.ToneCurve", which has type "Seq of points (Integer, Integer)".

Changed in pyexiv2:
assignee: nobody → Olivier Tilloy (osomon)
milestone: none → 0.3
status: Confirmed → Fix Committed
tags: added: xmp
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.