diff --git a/ChangeLog b/ChangeLog index f34ffc72..8272ecdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ will break the loader priority system - fix thumbnail autorot [janko] - fix a warning with magicksave with no delay array [chregu] +- fix a race in tiled tiff load [kleisauke] 20/6/19 started 8.9.0 - add vips_image_get/set_array_int() diff --git a/libvips/foreign/pdfload.c b/libvips/foreign/pdfload.c index 1a0bfbab..087b0428 100644 --- a/libvips/foreign/pdfload.c +++ b/libvips/foreign/pdfload.c @@ -362,18 +362,6 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load ) return( 0 ); } -static void -vips_foreign_load_pdf_minimise( VipsObject *object, VipsForeignLoadPdf *pdf ) -{ - VipsForeignLoadPdfClass *class = VIPS_FOREIGN_LOAD_PDF_GET_CLASS( pdf ); - -#ifdef DEBUG - printf( "vips_foreign_load_pdf_minimise: %p\n", pdf ); -#endif /*DEBUG*/ - - class->close( pdf ); -} - static int vips_foreign_load_pdf_generate( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) @@ -472,10 +460,9 @@ vips_foreign_load_pdf_load( VipsForeignLoad *load ) */ t[0] = vips_image_new(); - /* Close input immediately at end of read. + /* Don't minimise on ::minimise (end of computation): we support + * threaded read, and minimise will happen outside the cache lock. */ - g_signal_connect( t[0], "minimise", - G_CALLBACK( vips_foreign_load_pdf_minimise ), pdf ); vips_foreign_load_pdf_set_image( pdf, t[0] ); if( vips_image_generate( t[0], diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index dd460193..56935afb 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -507,7 +507,13 @@ rtiff_close_cb( VipsObject *object, Rtiff *rtiff ) static void rtiff_minimise_cb( VipsImage *image, Rtiff *rtiff ) { - if( rtiff->source ) + /* We must not minimised tiled images. These can be read from many + * threads, and this minimise handler is not inside the lock that our + * tilecache is using to guarantee single-threaded access to our + * source. + */ + if( !rtiff->header.tiled && + rtiff->source ) vips_source_minimise( rtiff->source ); }