Issue #1805 - Improve stack size limits for all targets.

This allows us to use a greater rendering depth for exceedingly-deep DOM trees
in layout, better matching what mainstream browsers are capable of. Note that
for 32-bit Windows the stack size MUST be set to larger than the default or Bad
Things Will Happen™ - we use 1.5 MB for this as a carefully-tuned value.

This needs to be capped specifically for JS use because some JavaScript
obfuscators deliberately trigger stack overflows and would lock up the browser
otherwise as long as there's still stack space to abuse. For web compatibility
we therefore limit this to 2MB in JS only (3x for ASAN) while still allowing
a greater depth for the layout engine.
This commit is contained in:
Moonchild 2022-07-15 11:56:12 +00:00 committed by roytam1
commit 5ed7e7d56d
4 changed files with 114 additions and 33 deletions

View file

@ -1256,7 +1256,7 @@ pref("javascript.options.wasm_baselinejit", false);
#endif
pref("javascript.options.native_regexp", true);
pref("javascript.options.parallel_parsing", true);
// ayncstack is used for debugging promises in devtools.
// asyncstack is used for debugging promises in devtools.
pref("javascript.options.asyncstack", false);
pref("javascript.options.throw_on_asmjs_validation_failure", false);
pref("javascript.options.ion.offthread_compilation", true);
@ -1306,6 +1306,18 @@ pref("javascript.options.shared_memory", true);
pref("javascript.options.throw_on_debuggee_would_run", false);
pref("javascript.options.dump_stack_on_debuggee_would_run", false);
// Set a thread stack quota limit for the main thread.
// Default 2MB for normal builds on all OSes. Tweak this if your custom
// build explicitly requires a larger or smaller stack limit
// Do NOT touch these values unless you know exactly what you are doing!
// Neither exceedingly large nor exceedingly small values are beneficial.
#ifdef MOZ_ASAN
pref("javascript.options.main_thread_stack_quota_cap", 6291456);
#else
pref("javascript.options.main_thread_stack_quota_cap", 2097152);
#endif
// advanced prefs
pref("advanced.mailftp", false);
pref("image.animation_mode", "normal");