Skip to content
Permalink
Browse files

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 kleisauke/net-vips#53
  • Loading branch information
jcupitt committed Jan 14, 2020
1 parent 70e8c6a commit 8752a76e668c5a176aeaa34502fe7212fa76415f
Showing with 10 additions and 16 deletions.
  1. +1 −0 ChangeLog
  2. +2 −15 libvips/foreign/pdfload.c
  3. +7 −1 libvips/foreign/tiff2vips.c
@@ -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()
@@ -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],
@@ -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 );
}

0 comments on commit 8752a76

Please sign in to comment.
You can’t perform that action at this time.