diff --git a/CLAUDE.md b/CLAUDE.md index 8c9c203..60c9616 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -65,7 +65,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl | `nice cargo build --release -j 2` | compile check, produces `target/release/nacre` | now | | `nice cargo test --release -j 2` | unit tests (44, ~16 s test-profile build then <1 s run; shares the S001 build) (util, settings, history, bookmarks, permissions, vault, dns, bridge loopback, download, adblock, keys, scripts, updates, inject, hub, theme, ui::widgets input, ui::paint, ui::pages::newtab) | first successful build; not alongside a build | | `src/selftest.rs` | in-app self test: `NACRE_SCRIPT=` runs script commands (listed at its top) | now | -| `tools/smoke.sh + + + + + +

Crash adblock

+ + + + diff --git a/tests/smoke/pages/crash-timers.html b/tests/smoke/pages/crash-timers.html new file mode 100644 index 0000000..4e3e422 --- /dev/null +++ b/tests/smoke/pages/crash-timers.html @@ -0,0 +1,40 @@ + + +crash-timers + + +

running

+ diff --git a/vendor/servo-script/event_loop/timers.rs b/vendor/servo-script/event_loop/timers.rs index eb16fa5..921a6fc 100644 --- a/vendor/servo-script/event_loop/timers.rs +++ b/vendor/servo-script/event_loop/timers.rs @@ -21,6 +21,7 @@ use net_traits::request::ParserMetadata; use rustc_hash::FxHashMap; use script_bindings::callback::{RootedCallback, TracedCallback}; use script_bindings::cell::DomRefCell; +use script_bindings::trace::RootedTraceableBox; use serde::{Deserialize, Serialize}; use servo_base::id::PipelineId; use servo_config::pref; @@ -348,7 +349,9 @@ impl OneshotTimers { // select timers to run to prevent firing timers // that were installed during fire of another timer - let mut timers_to_run = Vec::new(); + // Nacre patch (S031): the due timers leave the traced `self.timers`, so keep them rooted until they run; + // in a plain Vec a GC inside one callback swept the functions of the timers still waiting. + let mut timers_to_run = RootedTraceableBox::new(VecDeque::new()); loop { let mut timers = self.timers.borrow_mut(); @@ -357,10 +360,10 @@ impl OneshotTimers { break; } - timers_to_run.push(timers.pop_back().unwrap()); + timers_to_run.push_back(timers.pop_back().unwrap()); } - for timer in timers_to_run { + while let Some(timer) = timers_to_run.pop_front() { // Since timers can be coalesced together inside a task, // this loop can keep running, including after an interrupt of the JS, // and prevent a clean-shutdown of a JS-running thread. @@ -804,6 +807,8 @@ impl JsTimerTask { // prep for step ? in nested set_timeout_or_interval calls timers.nesting_level.set(self.nesting_level); + // Nacre patch (S031): `self` is off the traced timer list while it runs; root its function and arguments. + let _rooted_callback = RootedTraceableBox::new(self.callback.clone()); let _guard = ScriptThread::user_interacting_guard(); match self.callback { InternalTimerCallback::StringTimerCallback(ref code_str, ref fetch_info) => {