Skip to content

panic: RefCell already borrowed at components/script/dom/html/htmlmediaelement.rs:2116 #40720

@fred-wang

Description

@fred-wang

Minimal testcase:

<!DOCTYPE html>
<audio id="audioElement" src="about:blank">
<script>
  (new AudioContext({})).createMediaElementSource(audioElement);
</script>

System: Linux
Version: Version: Servo 0.0.2-cc4c762a7
Command: ./servo/servo


(servo:63433): GLib-GObject-CRITICAL **: 18:03:47.560: ../gobject/gsignal.c:2699: instance '0x7f3bd0039b70' has no handler with id '38'
RefCell already borrowed (thread Script(1,1), at components/script/dom/html/htmlmediaelement.rs:2132)
   0: servoshell::backtrace::print
             at /home/alaska/servo/ports/servoshell/backtrace.rs:18:5
   1: servoshell::panic_hook::panic_hook
             at /home/alaska/servo/ports/servoshell/panic_hook.rs:40:17
   2: core::ops::function::Fn::call
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:79:5
   3: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/alloc/src/boxed.rs:1999:9
      std::panicking::panic_with_hook
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:842:13
   4: std::panicking::panic_handler::{{closure}}
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:707:13
   5: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/sys/backtrace.rs:174:18
   6: __rustc::rust_begin_unwind
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:698:5
   7: core::panicking::panic_fmt
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/panicking.rs:75:14
   8: core::cell::panic_already_borrowed::do_panic::runtime
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/panic.rs:173:21
   9: core::cell::panic_already_borrowed::do_panic
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/intrinsics/mod.rs:2435:9
      core::cell::panic_already_borrowed
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/panic.rs:178:9
  10: core::cell::RefCell<T>::borrow_mut
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cell.rs:1090:25
  11: script::dom::bindings::cell::DomRefCell<T>::borrow_mut
             at /home/alaska/servo/components/script/dom/bindings/cell.rs:128:20
  12: script::dom::html::htmlmediaelement::HTMLMediaElement::reset_media_player
             at /home/alaska/servo/components/script/dom/html/htmlmediaelement.rs:2132:22
  13: script::dom::html::htmlmediaelement::HTMLMediaElement::media_element_load_algorithm
             at /home/alaska/servo/components/script/dom/html/htmlmediaelement.rs:1673:14
  14: script::dom::html::htmlmediaelement::HTMLMediaElement::set_audio_renderer
             at /home/alaska/servo/components/script/dom/html/htmlmediaelement.rs:2814:18
  15: script::dom::audio::mediaelementaudiosourcenode::MediaElementAudioSourceNode::new_inherited
             at /home/alaska/servo/components/script/dom/audio/mediaelementaudiosourcenode.rs:49:23
  16: script::dom::audio::mediaelementaudiosourcenode::MediaElementAudioSourceNode::new_with_proto
             at /home/alaska/servo/components/script/dom/audio/mediaelementaudiosourcenode.rs:74:20
  17: script::dom::audio::mediaelementaudiosourcenode::MediaElementAudioSourceNode::new
             at /home/alaska/servo/components/script/dom/audio/mediaelementaudiosourcenode.rs:63:9
  18: <script::dom::audio::audiocontext::AudioContext as script_bindings::codegen::GenericBindings::AudioContextBinding::AudioContext_Binding::AudioContextMethods<script::dom::bindings::codegen::DomTypeHolder::DomTypeHolder>>::CreateMediaElementSource
             at /home/alaska/servo/components/script/dom/audio/audiocontext.rs:262:9
  19: script_bindings::codegen::GenericBindings::AudioContextBinding::AudioContext_Binding::createMediaElementSource::{{closure}}::{{closure}}
             at /home/alaska/servo/target/debug/build/script_bindings-45e6937347fd0bfc/out/Bindings/AudioContextBinding.rs:591:83
  20: script_bindings::codegen::GenericBindings::AudioContextBinding::AudioContext_Binding::createMediaElementSource::{{closure}}
             at /home/alaska/servo/target/debug/build/script_bindings-45e6937347fd0bfc/out/Bindings/AudioContextBinding.rs:566:33
  21: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:310:21
  22: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:274:9
  23: std::panicking::catch_unwind::do_call
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:590:40
  24: __rust_try
  25: std::panicking::catch_unwind
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:553:19
      std::panic::catch_unwind
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:359:14
  26: mozjs::panic::wrap_panic
             at /home/alaska/.cargo/git/checkouts/mozjs-dd2a25693c61d87d/8bf5bf8/mozjs/src/panic.rs:22:11
  27: script_bindings::codegen::GenericBindings::AudioContextBinding::AudioContext_Binding::createMediaElementSource
             at /home/alaska/servo/target/debug/build/script_bindings-45e6937347fd0bfc/out/Bindings/AudioContextBinding.rs:566:5
  28: CallJitMethodOp
             at /home/runner/work/mozjs/mozjs/mozjs-sys/./src/jsglue.cpp:682:22
  29: script_bindings::utils::generic_call
             at /home/alaska/servo/components/script_bindings/utils.rs:404:5
  30: script_bindings::utils::generic_method
             at /home/alaska/servo/components/script_bindings/utils.rs:424:5
  31: _ZN2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstructENS_10CallReasonE
  32: _ZN2js9InterpretEP9JSContextRNS_8RunStateE
  33: _ZN2js9RunScriptEP9JSContextRNS_8RunStateE
  34: _ZN2js7ExecuteEP9JSContextN2JS6HandleIP8JSScriptEENS3_IP8JSObjectEENS2_13MutableHandleINS2_5ValueEEE
  35: _Z16JS_ExecuteScriptP9JSContextN2JS6HandleIP8JSScriptEENS1_13MutableHandleINS1_5ValueEEE
  36: mozjs::rust::wrappers::JS_ExecuteScript
             at /home/alaska/.cargo/git/checkouts/mozjs-dd2a25693c61d87d/8bf5bf8/mozjs/src/rust.rs:1275:51
  37: script::dom::globalscope::GlobalScope::evaluate_script_on_global_with_result
             at /home/alaska/servo/components/script/dom/globalscope.rs:2976:26
  38: script::dom::globalscope::GlobalScope::run_a_classic_script
             at /home/alaska/servo/components/script/dom/globalscope.rs:3566:18
  39: script::dom::html::htmlscriptelement::HTMLScriptElement::execute
             at /home/alaska/servo/components/script/dom/html/htmlscriptelement.rs:1057:55
  40: script::dom::html::htmlscriptelement::HTMLScriptElement::prepare
             at /home/alaska/servo/components/script/dom/html/htmlscriptelement.rs:916:30
  41: script::dom::servoparser::ServoParser::tokenize
             at /home/alaska/servo/components/script/dom/servoparser/mod.rs:715:20
  42: script::dom::servoparser::ServoParser::parse_sync
             at /home/alaska/servo/components/script/dom/servoparser/mod.rs:642:14
  43: script::dom::servoparser::ServoParser::parse_bytes_chunk
             at /home/alaska/servo/components/script/dom/servoparser/mod.rs:679:18
  44: script::dom::servoparser::ParserContext::load_document
             at /home/alaska/servo/components/script/dom/servoparser/mod.rs:1032:16
  45: <script::dom::servoparser::ParserContext as script::network_listener::FetchResponseListener>::process_response_eof
             at /home/alaska/servo/components/script/dom/servoparser/mod.rs:1353:18
  46: script::script_thread::ScriptThread::handle_fetch_eof
             at /home/alaska/servo/components/script/script_thread.rs:3588:21
  47: script::script_thread::ScriptThread::handle_navigation_response
             at /home/alaska/servo/components/script/script_thread.rs:3530:22
  48: script::script_thread::ScriptThread::handle_msg_from_script
             at /home/alaska/servo/components/script/script_thread.rs:1982:22
  49: script::script_thread::ScriptThread::handle_msgs::{{closure}}
             at /home/alaska/servo/components/script/script_thread.rs:1414:30
  50: script::script_thread::ScriptThread::profile_event
             at /home/alaska/servo/components/script/script_thread.rs:1650:13
  51: script::script_thread::ScriptThread::handle_msgs
             at /home/alaska/servo/components/script/script_thread.rs:1404:32
  52: script::script_thread::ScriptThread::start
             at /home/alaska/servo/components/script/script_thread.rs:1014:20
  53: <script::script_thread::ScriptThread as layout_api::ScriptThreadFactory>::create::{{closure}}::{{closure}}
             at /home/alaska/servo/components/script/script_thread.rs:466:38
  54: profile_traits::mem::ProfilerChan::run_with_memory_reporting
             at /home/alaska/servo/components/shared/profile/mem.rs:146:9
  55: <script::script_thread::ScriptThread as layout_api::ScriptThreadFactory>::create::{{closure}}
             at /home/alaska/servo/components/script/script_thread.rs:465:40
  56: std::sys::backtrace::__rust_begin_short_backtrace
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:158:18
  57: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:559:17
  58: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:274:9
  59: std::panicking::catch_unwind::do_call
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:590:40
  60: __rust_try
  61: std::panicking::catch_unwind
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:553:19
      std::panic::catch_unwind
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:359:14
      std::thread::Builder::spawn_unchecked_::{{closure}}
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:557:30
  62: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /home/alaska/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  63: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/alloc/src/boxed.rs:1985:9
      std::sys::thread::unix::Thread::new::thread_start
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/sys/thread/unix.rs:126:17
  64: start_thread
  65: __GI___clone3
[2025-11-18T17:03:50Z ERROR servoshell::panic_hook] RefCell already borrowed

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domInteracting with the DOM from web contentC-has-manual-testcaseE-less-complexStraightforward. Recommended for a new contributor.I-panicServo encounters a panic.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions