Skip to content

Commit 43db398

Browse files
committed
try to always set the min stack size
since musl users often don't know about this see #2761
1 parent 94d8a7d commit 43db398

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- add maxerror to gifsave [dloebl]
1818
- update libnsgif API [tlsa]
1919
- deprecate "properties" option to dzsave (now always on)
20+
- always set the min stack size for pthreads, if we can
2021

2122
26/11/21 started 8.12.3
2223
- better arg checking for hist_find_ndim [travisbell]

libvips/iofuncs/init.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ vips_init( const char *argv0 )
447447
static gboolean started = FALSE;
448448
static gboolean done = FALSE;
449449
const char *vips_min_stack_size;
450+
gint64 min_stack_size;
450451
const char *prefix;
451452
const char *libdir;
452453
#ifdef ENABLE_NLS
@@ -468,6 +469,14 @@ vips_init( const char *argv0 )
468469
return( 0 );
469470
started = TRUE;
470471

472+
/* Try to set a minimum stacksize, default 2mb. We need to do this
473+
* before any threads start.
474+
*/
475+
min_stack_size = 2 * 1024 * 1024;
476+
if( (vips_min_stack_size = g_getenv( "VIPS_MIN_STACK_SIZE" )) )
477+
min_stack_size = vips__parse_size( vips_min_stack_size );
478+
(void) set_stacksize( min_stack_size );
479+
471480
if( g_getenv( "VIPS_INFO" )
472481
#if ENABLE_DEPRECATED
473482
|| g_getenv( "IM_INFO" )
@@ -665,11 +674,6 @@ vips_init( const char *argv0 )
665674
if( g_getenv( "VIPS_BLOCK_UNTRUSTED" ) )
666675
vips_block_untrusted_set( TRUE );
667676

668-
/* Set a minimum stacksize, if we can.
669-
*/
670-
if( (vips_min_stack_size = g_getenv( "VIPS_MIN_STACK_SIZE" )) )
671-
(void) set_stacksize( vips__parse_size( vips_min_stack_size ) );
672-
673677
done = TRUE;
674678

675679
vips__thread_gate_stop( "init: startup" );

0 commit comments

Comments
 (0)