aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_init.c
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-04-11 15:05:51 +0200
committerRickard Green <[email protected]>2017-04-11 15:05:51 +0200
commit92a3b1a37182527d0bf8b6242d54e7fae6f4bbf9 (patch)
tree133119634987a6eeede055d644fe2f999ea3d318 /erts/emulator/beam/erl_init.c
parentb66834310f1d3f30a7b4d5c02753053d3f9d7ef8 (diff)
parent6520f78d4b878ff66adcf8d25de331d8ad06dd1d (diff)
downloadotp-92a3b1a37182527d0bf8b6242d54e7fae6f4bbf9.tar.gz
otp-92a3b1a37182527d0bf8b6242d54e7fae6f4bbf9.tar.bz2
otp-92a3b1a37182527d0bf8b6242d54e7fae6f4bbf9.zip
Merge branch 'rickard/pcre-8.40'
OTP-14331 * rickard/pcre-8.40: Update documentation Update README.pcre_update.md Stack guard for PCRE Adjust for incompatibility between PCRE 8.40 and perl 5.22.1 Generate re replacement and split tests with perl vsn 5.22.1 Fix re_SUITE:pcre_compile_workspace_overflow/1 Skip line with lockout of modifiers in PCRE tests Update tests for PCRE version 8.40 Update PCRE to version 8.40 Conflicts: erts/emulator/beam/beam_debug.c
Diffstat (limited to 'erts/emulator/beam/erl_init.c')
-rw-r--r--erts/emulator/beam/erl_init.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/erts/emulator/beam/erl_init.c b/erts/emulator/beam/erl_init.c
index 61477af316..56c0f19230 100644
--- a/erts/emulator/beam/erl_init.c
+++ b/erts/emulator/beam/erl_init.c
@@ -61,6 +61,9 @@
#define ERTS_DEFAULT_NO_ASYNC_THREADS 10
+#define ERTS_DEFAULT_SCHED_STACK_SIZE 256
+#define ERTS_MIN_SCHED_STACK_SIZE 20
+
/*
* The variables below (prefixed with etp_) are for erts/etc/unix/etp-commands
* only. Do not remove even though they aren't used elsewhere in the emulator!
@@ -125,6 +128,8 @@ const Eterm etp_hole_marker = ERTS_HOLE_MARKER;
const Eterm etp_hole_marker = 0;
#endif
+static int modified_sched_thread_suggested_stack_size = 0;
+
/*
* Note about VxWorks: All variables must be initialized by executable code,
* not by an initializer. Otherwise a new instance of the emulator will
@@ -1237,24 +1242,38 @@ early_init(int *argc, char **argv) /*
}
#ifndef ERTS_SMP
+
+void *erts_scheduler_stack_limit;
+
+
static void set_main_stack_size(void)
{
- if (erts_sched_thread_suggested_stack_size > 0) {
+ char c;
+ UWord stacksize;
# if HAVE_DECL_GETRLIMIT && HAVE_DECL_SETRLIMIT && HAVE_DECL_RLIMIT_STACK
- struct rlimit rl;
- int bytes = erts_sched_thread_suggested_stack_size * sizeof(Uint) * 1024;
- if (getrlimit(RLIMIT_STACK, &rl) != 0 ||
- (rl.rlim_cur = bytes, setrlimit(RLIMIT_STACK, &rl) != 0)) {
- erts_fprintf(stderr, "failed to set stack size for scheduler "
- "thread to %d bytes\n", bytes);
- erts_usage();
- }
+ struct rlimit rl;
+ int bytes;
+ stacksize = erts_sched_thread_suggested_stack_size * sizeof(Uint) * 1024;
+ /* Add some extra pages... neede by some systems... */
+ bytes = (int) stacksize + 3*erts_sys_get_page_size();
+ if (getrlimit(RLIMIT_STACK, &rl) != 0 ||
+ (rl.rlim_cur = bytes, setrlimit(RLIMIT_STACK, &rl) != 0)) {
+ erts_fprintf(stderr, "failed to set stack size for scheduler "
+ "thread to %d bytes\n", bytes);
+ erts_usage();
+ }
# else
+ if (modified_sched_thread_suggested_stack_size) {
erts_fprintf(stderr, "no OS support for dynamic stack size limit\n");
- erts_usage();
-# endif
+ erts_usage();
}
+ /* Be conservative and hope it is not more than 64 kWords... */
+ stacksize = 64*1024*sizeof(void *);
+# endif
+
+ erts_scheduler_stack_limit = erts_calc_stacklimit(&c, stacksize);
}
+
#endif
void
@@ -1299,12 +1318,11 @@ erl_start(int argc, char **argv)
port_tab_sz_ignore_files = 1;
}
-#if (defined(__APPLE__) && defined(__MACH__)) || defined(__DARWIN__)
/*
- * The default stack size on MacOS X is too small for pcre.
+ * A default stack size suitable for pcre which might use quite
+ * a lot of stack.
*/
- erts_sched_thread_suggested_stack_size = 256;
-#endif
+ erts_sched_thread_suggested_stack_size = ERTS_DEFAULT_SCHED_STACK_SIZE;
#ifdef DEBUG
verbose = DEBUG_DEFAULT;
@@ -1927,6 +1945,7 @@ erl_start(int argc, char **argv)
/* suggested stack size (Kilo Words) for scheduler threads */
arg = get_arg(sub_param+2, argv[i+1], &i);
erts_sched_thread_suggested_stack_size = atoi(arg);
+ modified_sched_thread_suggested_stack_size = 1;
if ((erts_sched_thread_suggested_stack_size
< ERTS_SCHED_THREAD_MIN_STACK_SIZE)
@@ -2236,6 +2255,9 @@ erl_start(int argc, char **argv)
boot_argc = argc - i; /* Number of arguments to init */
boot_argv = &argv[i];
+ if (erts_sched_thread_suggested_stack_size < ERTS_MIN_SCHED_STACK_SIZE)
+ erts_sched_thread_suggested_stack_size = ERTS_MIN_SCHED_STACK_SIZE;
+
erl_init(ncpu,
proc_tab_sz,
legacy_proc_tab,