From f3613e508241920890285c5b7bbaecbaa6b6b09e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 8 Jul 2015 21:18:23 +0200 Subject: [PATCH] test,unix: reduce stack size of watchdog threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some 32 bits architectures, linux/mips and linux/mipsel in particular, suffer from address space fragmentation when spawning many threads with the default 8 MB stack size. The watchdog threads don't need much stack space, all they do is sleep until the monitored process exits, so lower it to 256 kB. Fixes: https://github.com/libuv/libuv/issues/408 PR-URL: https://github.com/libuv/libuv/pull/429 Reviewed-By: Saúl Ibarra Corretgé --- test/runner-unix.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/runner-unix.c b/test/runner-unix.c index 34de6dc2..be921dea 100644 --- a/test/runner-unix.c +++ b/test/runner-unix.c @@ -174,6 +174,7 @@ int process_wait(process_info_t* vec, int n, int timeout) { process_info_t* p; dowait_args args; pthread_t tid; + pthread_attr_t attr; unsigned int elapsed_ms; struct timeval timebase; struct timeval tv; @@ -202,7 +203,17 @@ int process_wait(process_info_t* vec, int n, int timeout) { return -1; } - r = pthread_create(&tid, NULL, dowait, &args); + if (pthread_attr_init(&attr)) + abort(); + + if (pthread_attr_setstacksize(&attr, 256 * 1024)) + abort(); + + r = pthread_create(&tid, &attr, dowait, &args); + + if (pthread_attr_destroy(&attr)) + abort(); + if (r) { perror("pthread_create()"); retval = -1;