try to always set the min stack size

since musl users often don't know about this

see https://github.com/libvips/libvips/issues/2761
This commit is contained in:
John Cupitt 2022-04-19 16:41:18 +01:00
parent 94d8a7d993
commit 43db3985d0
2 changed files with 10 additions and 5 deletions

View File

@ -17,6 +17,7 @@
- add maxerror to gifsave [dloebl]
- update libnsgif API [tlsa]
- deprecate "properties" option to dzsave (now always on)
- always set the min stack size for pthreads, if we can
26/11/21 started 8.12.3
- better arg checking for hist_find_ndim [travisbell]

View File

@ -447,6 +447,7 @@ vips_init( const char *argv0 )
static gboolean started = FALSE;
static gboolean done = FALSE;
const char *vips_min_stack_size;
gint64 min_stack_size;
const char *prefix;
const char *libdir;
#ifdef ENABLE_NLS
@ -468,6 +469,14 @@ vips_init( const char *argv0 )
return( 0 );
started = TRUE;
/* Try to set a minimum stacksize, default 2mb. We need to do this
* before any threads start.
*/
min_stack_size = 2 * 1024 * 1024;
if( (vips_min_stack_size = g_getenv( "VIPS_MIN_STACK_SIZE" )) )
min_stack_size = vips__parse_size( vips_min_stack_size );
(void) set_stacksize( min_stack_size );
if( g_getenv( "VIPS_INFO" )
#if ENABLE_DEPRECATED
|| g_getenv( "IM_INFO" )
@ -665,11 +674,6 @@ vips_init( const char *argv0 )
if( g_getenv( "VIPS_BLOCK_UNTRUSTED" ) )
vips_block_untrusted_set( TRUE );
/* Set a minimum stacksize, if we can.
*/
if( (vips_min_stack_size = g_getenv( "VIPS_MIN_STACK_SIZE" )) )
(void) set_stacksize( vips__parse_size( vips_min_stack_size ) );
done = TRUE;
vips__thread_gate_stop( "init: startup" );