elementary / photos

Photo viewer and organizer designed for elementary OS
https://elementary.io
GNU Lesser General Public License v2.1
105 stars 38 forks source link

Segfault when reading exif metadata #647

Closed asonix closed 3 years ago

asonix commented 3 years ago

What Happened?

There's an image on my computer with the following exif timestamp data: (captured with imagemagick's identify -verbose

  Properties:
    date:create: 2019-11-13T09:27:04-06:00
    date:modify: 2018-10-13T00:24:28-05:00
    exif:DateTime: 2018:10:13 24:24:27

When Photos attempts to import this image, it crashes (note: shotwell does not crash, and photos on elementary 5.0 did not either).

The backtrace indicates it's failing to parse the exif:DateTime 2018:10:13 24:24:27 into a representable date, and so converting the malformed date to a unix timestamp segfaults.

Thread 36 "pool-io.element" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffb57fa700 (LWP 57332)]
0x00007ffff7ebc668 in g_date_time_to_unix () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
(gdb) backtrace
#0  0x00007ffff7ebc668 in g_date_time_to_unix () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x0000555555678c29 in metadata_date_time_from_exif_date_time (date_time_s=0x7fff98324160 "2018:10:13 24:24:27", timestamp=0x7fffb57f8f38) at ../src/MediaMetadata.vala:121
#2  0x0000555555678417 in metadata_date_time_construct_from_exifPython Exception <class 'ValueError'> Variable 'static_fundamental_type_nodes' not found.: 
 (object_type=, label=0x7fff98324160 "2018:10:13 24:24:27", error=0x7fffb57f8fb0)
    at ../src/MediaMetadata.vala:68
#3  0x0000555555678554 in metadata_date_time_new_from_exif (label=0x7fff98324160 "2018:10:13 24:24:27", error=0x7fffb57f8fb0) at ../src/MediaMetadata.vala:67
#4  0x000055555581dcf2 in photo_metadata_get_date_time (self=0x55555b1cbb60, tag=0x7fff9831e1b0 "Exif.Image.DateTime") at ../src/photos/PhotoMetadata.vala:568
#5  0x000055555581df08 in photo_metadata_get_first_date_time (self=0x55555b1cbb60, tags=0x7fffbc00e370, tags_length1=6) at ../src/photos/PhotoMetadata.vala:579
#6  0x000055555581f03c in photo_metadata_get_exposure_date_time (self=0x55555b1cbb60) at ../src/photos/PhotoMetadata.vala:733
#7  0x000055555569fbb8 in photo_prepare_for_importPython Exception <class 'ValueError'> Variable 'static_fundamental_type_nodes' not found.: 
 (params=) at ../src/Photo.vala:1141
#8  0x00005555555f6940 in prepared_file_import_job_real_execute (base=0x55555786a640) at ../src/BatchImport.vala:2001
#9  0x000055555587c763 in background_job_execute (self=0x55555786a640) at ../src/threads/BackgroundJob.vala:136
#10 0x0000555555881352 in workers_thread_startPython Exception <class 'ValueError'> Variable 'static_fundamental_type_nodes' not found.: 
 (self=, ignored=0x55555786a640) at ../src/threads/Workers.vala:108
#11 0x0000555555880795 in _workers_thread_start_gfunc (data=0x55555786a640, self=0x55555ad593a0) at ../src/threads/Workers.vala:43
#12 0x00007ffff7eff374 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#13 0x00007ffff7efead1 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007ffff692f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#15 0x00007ffff6856293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Steps to Reproduce

  1. Create an image with an exif:DateTime of 2018:10:13 24:24:27 in Photos' watched directory
  2. Allow photos to attempt auto-importing the image

Expected Behavior

It shouldn't crash form a malformed exif timestamp

OS Version

6.x (Odin)

Software Version

Log Output

** (io.elementary.photos:57273): DEBUG: 17:14:39.136: BatchImport.vala:1985: Importing /home/asonix/Pictures/shotwell/2018/10/14/IMG_20181013_002427.jpg

Hardware Info

Linux firestar 5.11.0-37-generic #41~20.04.2-Ubuntu SMP Fri Sep 24 09:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

01:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)

nvidia-driver-470/focal,now 470.74-0ubuntu0.20.04.1 amd64 [installed]