diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index bc1f8f7e1bc..3f9cdf8a1bb 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -444,6 +444,7 @@ pub struct Runtime { rt: RustRuntime, pub microtask_queue: Rc, job_queue: *mut JobQueue, + networking_task_src: Option>, } impl Drop for Runtime { @@ -561,12 +562,13 @@ unsafe fn new_rt_and_cx_with_parent( networking_task_src.queue_unconditionally(task).is_ok() } + let mut networking_task_src_ptr = std::ptr::null_mut(); if let Some(source) = networking_task_source { - let networking_task_src = Box::new(source); + networking_task_src_ptr = Box::into_raw(Box::new(source)); InitDispatchToEventLoop( cx, Some(dispatch_to_event_loop), - Box::into_raw(networking_task_src) as *mut c_void, + networking_task_src_ptr as *mut c_void, ); } @@ -721,6 +723,8 @@ unsafe fn new_rt_and_cx_with_parent( rt: runtime, microtask_queue, job_queue, + networking_task_src: (!networking_task_src_ptr.is_null()) + .then(|| Box::from_raw(networking_task_src_ptr)), } } diff --git a/support/suppressed_leaks_for_asan.txt b/support/suppressed_leaks_for_asan.txt index 71647c0578f..70b895819e7 100644 --- a/support/suppressed_leaks_for_asan.txt +++ b/support/suppressed_leaks_for_asan.txt @@ -1,5 +1,11 @@ # intentional Box::leak, introduced here: https://github.com/servo/stylo/blob/f4cde5d89d03db92d111eaa4b4b34e622b6eecac/style/sharing/mod.rs#L481 leak:style::sharing::SHARING_CACHE_KEY::__init +# intentional Box::leak, introduced here: https://github.com/servo/stylo/blob/80292f83789ec9d0c66f73ee7e6e142f7478d167/style/bloom.rs#L22 +leak:style::bloom::BLOOM_KEY::__init # std::sync::LazyLock never frees memory because it never runs destructors, see https://doc.rust-lang.org/std/sync/struct.LazyLock.html#examples -leak:std::sync::LazyLock \ No newline at end of file +leak:std::sync::LazyLock + +# lazy_static never frees memory because it never runs destructors, see https://docs.rs/lazy_static/1.4.0/lazy_static/index.html#semantics +# Needed because transitive dependency are still using it +leak:lazy_static::lazy::Lazy*::get