fix a race in tiled tiffload and pdfload

We weer minimising sources in the ::minimise handler, but this is called
outside the lock that protects _generate. This patch removes minimise in
this case.

See https://github.com/kleisauke/net-vips/issues/53
This commit is contained in:
John Cupitt 2020-01-14 18:06:12 +00:00
parent 70e8c6a61f
commit 8752a76e66
3 changed files with 10 additions and 16 deletions

View File

@ -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()

View File

@ -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],

View File

@ -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 );
}