Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<link> elements need to clear any previous stylesheet before loading a new one #15101

Closed
nwjsmith opened this issue Jan 18, 2017 · 7 comments
Closed

Comments

@nwjsmith
Copy link

@nwjsmith nwjsmith commented Jan 18, 2017

assertion failed: self.stylesheet.borrow().is_none()

URL:

Servo Version:

Servo 0.0.1-f010fb5

Backtrace:


WARNING: <Constellation>: Frame FrameId { namespace_id: PipelineNamespaceId(0), index: FrameIndex(0) } iterated after closure.
WARNING: <Constellation>: Frame FrameId { namespace_id: PipelineNamespaceId(0), index: FrameIndex(0) } iterated after closure.
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }>: stop_parsing not implemented, full speed ahead!
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }>: stop_parsing not implemented, full speed ahead!
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }>: stop_parsing not implemented, full speed ahead!
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(2) }>: stop_parsing not implemented, full speed ahead!
WARNING: <Constellation>: Pipeline (0,1) has no parent.
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(2) }>: stop_parsing not implemented, full speed ahead!
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }>: stop_parsing not implemented, full speed ahead!
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: Message sent to closed pipeline (1,5).
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(5) }>: freeze sent to nonexistent pipeline
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(6) }>: freeze sent to nonexistent pipeline
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(7) }>: stop_parsing not implemented, full speed ahead!
WARNING: <ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(7) }>: Panic hook called.
ERROR: assertion failed: self.stylesheet.borrow().is_none()

stack backtrace:
   0:        0x10bfe70de - backtrace::backtrace::trace::hf62db13292993b7b
   1:        0x10bfe73ec - backtrace::capture::Backtrace::new::hd6fb6e83f9059b0d
   2:        0x10bf1f0f4 - constellation::constellation::log_entry::h19b052c781087594
   3:        0x10bf1e102 - <constellation::constellation::FromCompositorLogger as log::Log>::log::h36228ba81e93d85d
   4:        0x10cf38fc1 - log::__log::h2e9b720ead5e7b53
   5:        0x10b335660 - servo::main::{{closure}}::he0211114582e5524
   6:        0x10cf806e4 - std::panicking::rust_panic_with_hook::h33761bada49f3713
   7:        0x10b50e594 - std::panicking::begin_panic::h5871bdf0eba452a7
   8:        0x10baa2f8c - <script::stylesheet_loader::StylesheetContext as net_traits::FetchResponseListener>::process_response_eof::hbaa185f211e49eef
   9:        0x10ba50c3d - <script::network_listener::ListenerRunnable<A, Listener> as script::script_thread::Runnable>::handler::h0eac68b229ae0c48
  10:        0x10ba59272 - <script::script_thread::CancellableRunnable<T> as script::script_thread::Runnable>::handler::hb7e5f8f53abfd37a
  11:        0x10ba76f28 - script::script_thread::ScriptThread::handle_msg_from_script::hbe22e1fbcff75733
  12:        0x10ba6f695 - script::script_thread::ScriptThread::handle_msgs::{{closure}}::h994055b9195ea3dd
  13:        0x10ba6a925 - script::script_thread::ScriptThread::handle_msgs::h3e82c4a9be9c120b
  14:        0x10b562ae7 - std::panicking::try::do_call::h317093b315bfb0b1
  15:        0x10cf815fa - __rust_maybe_catch_panic
  16:        0x10b72b22a - <F as alloc::boxed::FnBox<A>>::call_box::he06e05fd65345e4b
  17:        0x10cf7f664 - std::sys::imp::thread::Thread::new::thread_start::he1b44499d44cc4a4
  18:     0x7fff9f3b0aaa - _pthread_body
  19:     0x7fff9f3b09f6 - _pthread_start

This report was generated by the browser.html issue reporter.

@jdm
Copy link
Member

@jdm jdm commented Jan 18, 2017

@nwjsmith Do you know what page you were looking at when you encountered this?

@nwjsmith
Copy link
Author

@nwjsmith nwjsmith commented Jan 18, 2017

@jdm
Copy link
Member

@jdm jdm commented Jan 18, 2017

(lldb) bt
* thread #30: tid = 0x7b6710, 0x0000000106710144 servo`std::panicking::rust_panic + 4 at panicking.rs:586, stop reason = breakpoint 1.1
  * frame #0: 0x0000000106710144 servo`std::panicking::rust_panic + 4 at panicking.rs:586
    frame #1: 0x0000000106710115 servo`std::panicking::rust_panic_with_hook + 437 at panicking.rs:571
    frame #2: 0x00000001025ad3b4 servo`std::panicking::begin_panic<&str>(msg=&str at 0x00000001259f98f0, file_line=0x00000001084d3ae0) + 29372612 at panicking.rs:517
    frame #3: 0x0000000102c50dd4 servo`bincode::serde::writer::{{impl}}::serialize_f32<collections::vec::Vec<u8>>(self=0x0000000125ef9860, v=0.00000000000000000000000000000000000000000000140129846) + 39377044 at writer.rs:148
    frame #4: 0x0000000100f6c2af servo`script::stylesheet_loader::{{impl}}::process_response_eof(self=0x0000000125e67660, status=Result<(), net_traits::NetworkError> at 0x00000001259f9c30) + 2079 at stylesheet_loader.rs:144
    frame #5: 0x0000000100d443ac servo`net_traits::{{impl}}::process<script::stylesheet_loader::StylesheetContext>(self=FetchResponseMsg at 0x00000001259fa510, listener=0x0000000125e67660) + 716 at lib.rs:239
    frame #6: 0x0000000100f66608 servo`script::network_listener::{{impl}}::handler<net_traits::FetchResponseMsg,script::stylesheet_loader::StylesheetContext>(self=0x000000011c07df80) + 408 at network_listener.rs:63
    frame #7: 0x0000000100f67a5d servo`script::script_thread::{{impl}}::handler<script::network_listener::ListenerRunnable<net_traits::FetchResponseMsg, script::stylesheet_loader::StylesheetContext>>(self=0x000000011c00c390) + 29 at script_thread.rs:219
    frame #8: 0x0000000102cfd974 servo`bincode::serde::writer::{{impl}}::serialize_str<collections::vec::Vec<u8>>(self=0x000000011c00c390, v=&str at 0x00000001259fb458) + 40083748 at writer.rs:156
    frame #9: 0x0000000102cf9f2f servo`script::script_thread::ScriptThread::handle_msgs::_$u7b$$u7b$closure$u7d$$u7d$::hd50a2e97e5682c7a + 383 at writer.rs:154
    frame #10: 0x0000000102cfb862 servo`bincode::serde::writer::{{impl}}::serialize_f64<collections::vec::Vec<u8>>(self=0x0000000115f4afb8, v=0) + 40075938 at writer.rs:152
    frame #11: 0x0000000102cf889b servo`bincode::serde::writer::{{impl}}::serialize_some<collections::vec::Vec<u8>,&msg::constellation_msg::FrameId>(self=0x0000000000000000, v=0x0000000100000000) + 40057707 at <try macros>:4
    frame #12: 0x0000000102cf6de6 servo`bincode::serde::writer::{{impl}}::serialize_f64<collections::vec::Vec<u8>>(self=0x0000000110618150, v=2.1220257683983337E-314) + 40056870 at writer.rs:153
    frame #13: 0x0000000102cf3445 servo`bincode::serde::writer::{{impl}}::serialize_u8<collections::vec::Vec<u8>>(self=0x00000001259fece8, v='\0') + 40042373 at writer.rs:108
    frame #14: 0x0000000102267e97 servo`bincode::serde::writer::{{impl}}::serialize_map<collections::vec::Vec<u8>>(self=0x0000000000000000, len=Option<usize> at 0x00000001259fea60) + 28985191 at writer.rs:252
    frame #15: 0x0000000102cf3af5 servo`bincode::serde::writer::{{impl}}::serialize_str<collections::vec::Vec<u8>>(self=0x0000000000000001, v=&str at 0x00000001259ff188) + 40043173 at <try macros>:6
    frame #16: 0x0000000102b4350b servo`bincode::serde::writer::{{impl}}::serialize_f32<collections::vec::Vec<u8>>(self=0x0000660300000000, v=0.00000000000000000000000000000000000000000000140129846) + 38272971 at writer.rs:148
    frame #17: 0x0000000102697d1a servo`bincode::serde::writer::{{impl}}::serialize_i32<collections::vec::Vec<u8>>(self=0x0000660300000000, v=1) + 33375962 at writer.rs:136
    frame #18: 0x0000000106710f8b servo`panic_unwind::__rust_maybe_catch_panic + 27 at lib.rs:98
    frame #19: 0x00000001026755b4 servo`bincode::serde::writer::{{impl}}::serialize_f64<collections::vec::Vec<u8>>(self=0x00007fff92935cd1, v=0) + 33234932 at writer.rs:152
    frame #20: 0x000000010258e375 servo`bincode::serde::writer::{{impl}}::serialize_f32<collections::vec::Vec<u8>>(self=0x0000000000000000, v=0.0000000000000000000000000000000000000000365949094) + 32288309 at writer.rs:148
    frame #21: 0x00000001025ace6c servo`bincode::serde::writer::{{impl}}::serialize_i32<collections::vec::Vec<u8>>(self=0x0000000000000000, v=0) + 32413740 at writer.rs:136
    frame #22: 0x0000000102953f33 servo`bincode::serde::writer::{{impl}}::serialize_u8<collections::vec::Vec<u8>>(self=0x0000660300000000, v='\0') + 36244083 at writer.rs:108
    frame #23: 0x000000010670eff5 servo`std::sys::imp::thread::{{impl}}::new::thread_start [inlined] alloc::boxed::{{impl}}::call_once<(),()> + 37 at boxed.rs:615
    frame #24: 0x000000010670efef servo`std::sys::imp::thread::{{impl}}::new::thread_start [inlined] std::sys_common::thread::start_thread + 15 at thread.rs:21
    frame #25: 0x000000010670efe0 servo`std::sys::imp::thread::{{impl}}::new::thread_start + 16 at thread.rs:84
    frame #26: 0x00007fff8e409899 libsystem_pthread.dylib`_pthread_body + 138
    frame #27: 0x00007fff8e40972a libsystem_pthread.dylib`_pthread_start + 137
    frame #28: 0x00007fff8e40dfc9 libsystem_pthread.dylib`thread_start + 13

Frame 3 is bogus; that's really HTMLLinkElement::set_stylesheet where the assertion lives.

@jdm
Copy link
Member

@jdm jdm commented Jan 18, 2017

The stack for StylesheetLoader::load shows the stylesheet is loaded when the <link> element is appended to the document:

(lldb) bt
* thread #29: tid = 0x7c20a5, 0x00000001020b9e77 servo`script::stylesheet_loader::{{impl}}::load(self=0x0000000122ff5210, source=StylesheetContextSource at 0x0000000122ff4690, cors_setting=Option<net_traits::request::CorsSettings> at 0x0000000122ff46b8, integrity_metadata=String at 0x0000000122ff46c0) + 423 at stylesheet_loader.rs:201, stop reason = breakpoint 4.1
  * frame #0: 0x00000001020b9e77 servo`script::stylesheet_loader::{{impl}}::load(self=0x0000000122ff5210, source=StylesheetContextSource at 0x0000000122ff4690, cors_setting=Option<net_traits::request::CorsSettings> at 0x0000000122ff46b8, integrity_metadata=String at 0x0000000122ff46c0) + 423 at stylesheet_loader.rs:201
    frame #1: 0x0000000101f3296d servo`script::dom::htmllinkelement::{{impl}}::handle_stylesheet_url(self=0x00000001234e0700, href=&str at 0x0000000122ff4fd0) + 2413 at htmllinkelement.rs:266
    frame #2: 0x0000000101f31e8a servo`script::dom::htmllinkelement::{{impl}}::bind_to_tree(self=0x00000001234e0700, tree_in_doc=true) + 730 at htmllinkelement.rs:207
    frame #3: 0x0000000101f6cfdd servo`script::dom::node::{{impl}}::add_child(self=0x000000012342a180, new_child=0x00000001234e0700, before=Option<&script::dom::node::Node> at 0x0000000122ff5598) + 2413 at node.rs:247
    frame #4: 0x0000000101f7ef9b servo`script::dom::node::{{impl}}::insert(node=0x00000001234e0700, parent=0x000000012342a180, child=Option<&script::dom::node::Node> at 0x0000000122ff5948, suppress_observers=Unsuppressed) + 1931 at node.rs:1591
    frame #5: 0x0000000101f7e6a9 servo`script::dom::node::{{impl}}::pre_insert(node=0x00000001234e0700, parent=0x000000012342a180, child=Option<&script::dom::node::Node> at 0x0000000122ff5c30) + 825 at node.rs:1535
    frame #6: 0x0000000101f83b54 servo`script::dom::node::{{impl}}::InsertBefore(self=0x000000012342a180, node=0x00000001234e0700, child=Option<&script::dom::node::Node> at 0x0000000122ff5d98) + 84 at node.rs:1995
    frame #7: 0x0000000102528a17 servo`script::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::insertBefore::{{closure}} + 2039 at mod.rs:165
    frame #8: 0x0000000102848e99 servo`core::ops::FnOnce::call_once::hc14d48e53c4ffd27 + 9
    frame #9: 0x0000000101c6717b servo`std::panic::{{impl}}::call_once<bool,closure>(self=AssertUnwindSafe<closure> at 0x0000000122ff61c0, _args=<unavailable>) + 91 at panic.rs:296
    frame #10: 0x0000000101306144 servo`std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,bool>(data=0x0000000122ff63e0) + 292 at panicking.rs:460
    frame #11: 0x00000001058ba32b servo`panic_unwind::__rust_maybe_catch_panic + 27 at lib.rs:98
    frame #12: 0x00000001010844c0 servo`std::panicking::try<bool,std::panic::AssertUnwindSafe<closure>>(f=AssertUnwindSafe<closure> at 0x0000000122ff63a0) + 320 at panicking.rs:436
    frame #13: 0x0000000100f59bf7 servo`std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,bool>(f=AssertUnwindSafe<closure> at 0x0000000122ff64e8) + 103 at panic.rs:361
    frame #14: 0x0000000100ac762d servo`js::panic::wrap_panic<std::panic::AssertUnwindSafe<closure>,bool>(function=AssertUnwindSafe<closure> at 0x0000000122ff6560, generic_return_type=false) + 173 at panic.rs:22
    frame #15: 0x00000001025281fe servo`script::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::insertBefore(cx=0x0000000111822600, _obj=Handle<*mut js::jsapi::JSObject> at 0x0000000122ff6630, this=0x000000012342a180, args=0x0000000122ff66e8) + 126 at mod.rs:165
    frame #16: 0x0000000103c6d8a1 servo`CallJitMethodOp(info=0x0000000107178448, cx=0x0000000111822600, thisObj=JS::HandleObject at 0x0000000122ff6738, specializedThis=0x000000012342a180, argc=2, vp=0x000000010e032580) + 241 at jsglue.cpp:472
    frame #17: 0x0000000101e0c781 servo`script::dom::bindings::utils::generic_call(cx=0x0000000111822600, argc=2, vp=0x000000010e032580, is_lenient=false, call=0x0000000103c6d7b0) + 3169 at utils.rs:446
    frame #18: 0x0000000101e0c8c2 servo`script::dom::bindings::utils::generic_method(cx=0x0000000111822600, argc=2, vp=0x000000010e032580) + 66 at utils.rs:454
    frame #19: 0x00000001040fbe86 servo`js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) [inlined] js::CallJSNative(native=<unavailable>)(JSContext*, unsigned int, JS::Value*), JS::CallArgs const&) + 226 at jscntxtinlines.h:232
    frame #20: 0x00000001040fbda4 servo`js::InternalCallOrConstruct(cx=0x0000000111822600, args=0x0000000122ff6f40, construct=<unavailable>) + 692 at Interpreter.cpp:453
    frame #21: 0x00000001040f48f3 servo`Interpret(JSContext*, js::RunState&) [inlined] js::CallFromStack(cx=<unavailable>, args=0x000000010e032590) + 63955 at Interpreter.cpp:504
    frame #22: 0x00000001040f48e8 servo`Interpret(cx=<unavailable>, state=<unavailable>) + 63944 at Interpreter.cpp:2873
    frame #23: 0x00000001040e4eeb servo`js::RunScript(cx=0x0000000111822600, state=0x0000000122ff7700) + 411 at Interpreter.cpp:399
    frame #24: 0x00000001040fc16e servo`js::InternalCallOrConstruct(cx=0x0000000111822600, args=<unavailable>, construct=<unavailable>) + 1662 at Interpreter.cpp:471
    frame #25: 0x0000000103d98771 servo`js::jit::DoCallFallback(cx=0x0000000111822600, frame=0x0000000122ff7ad8, stub_=0x000000011183a318, argc=2, vp=0x0000000122ff7a60, res=<unavailable>) + 1329 at BaselineIC.cpp:5970
    frame #26: 0x000000011b7d6759

However, it is then loaded again when the <link> element's href attribute is mutated:

(lldb) bt
* thread #29: tid = 0x7c20a5, 0x00000001020b9e77 servo`script::stylesheet_loader::{{impl}}::load(self=0x0000000122ff54e0, source=StylesheetContextSource at 0x0000000122ff4960, cors_setting=Option<net_traits::request::CorsSettings> at 0x0000000122ff4988, integrity_metadata=String at 0x0000000122ff4990) + 423 at stylesheet_loader.rs:201, stop reason = breakpoint 4.1
  * frame #0: 0x00000001020b9e77 servo`script::stylesheet_loader::{{impl}}::load(self=0x0000000122ff54e0, source=StylesheetContextSource at 0x0000000122ff4960, cors_setting=Option<net_traits::request::CorsSettings> at 0x0000000122ff4988, integrity_metadata=String at 0x0000000122ff4990) + 423 at stylesheet_loader.rs:201
    frame #1: 0x0000000101f3296d servo`script::dom::htmllinkelement::{{impl}}::handle_stylesheet_url(self=0x00000001234e0700, href=&str at 0x0000000122ff52a0) + 2413 at htmllinkelement.rs:266
    frame #2: 0x0000000101f317e5 servo`script::dom::htmllinkelement::{{impl}}::attribute_mutated(self=0x00000001234e0700, attr=0x000000012344fc80, mutation=AttributeMutation at 0x0000000122ff57a8) + 2293 at htmllinkelement.rs:178
    frame #3: 0x0000000101cf3c43 servo`script::dom::attr::{{impl}}::set_value(self=0x000000012344fc80, value=AttrValue at 0x0000000122ff59b0, owner=0x00000001234e0700) + 595 at attr.rs:176
    frame #4: 0x0000000101ea9a6c servo`script::dom::element::{{impl}}::set_first_matching_attribute<closure>(self=0x00000001234e0700, local_name=Atom<html5ever_atoms::LocalNameStaticSet> at 0x0000000122ff5b38, value=AttrValue at 0x0000000122ff5b48, name=Atom<html5ever_atoms::LocalNameStaticSet> at 0x0000000122ff5b88, namespace=Atom<html5ever_atoms::NamespaceStaticSet> at 0x0000000122ff5b98, prefix=Option<string_cache::atom::Atom<html5ever_atoms::PrefixStaticSet>> at 0x0000000122ff5ba8, find=closure at 0x0000000122ff5bb8) + 1276 at element.rs:1066
    frame #5: 0x0000000101ea7d3d servo`script::dom::element::{{impl}}::set_attribute(self=0x00000001234e0700, name=0x0000000122ff6210, value=AttrValue at 0x0000000122ff5e40) + 1293 at element.rs:1022
    frame #6: 0x0000000101eacd43 servo`script::dom::element::{{impl}}::set_string_attribute(self=0x00000001234e0700, local_name=0x0000000122ff6210, value=DOMString at 0x0000000122ff60b8) + 467 at element.rs:1175
    frame #7: 0x000000010281994d servo`script::dom::htmllinkelement::{{impl}}::SetMedia(self=0x00000001234e0700, value=DOMString at 0x0000000122ff61d0) + 189 at htmllinkelement.rs:343
    frame #8: 0x0000000102461905 servo`script::dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementBinding::set_media::{{closure}} + 789 at mod.rs:165
    frame #9: 0x0000000102843209 servo`core::ops::FnOnce::call_once::h69a05db6efb42a3d + 9
    frame #10: 0x0000000101c38c4b servo`std::panic::{{impl}}::call_once<bool,closure>(self=AssertUnwindSafe<closure> at 0x0000000122ff6450, _args=<unavailable>) + 91 at panic.rs:296
    frame #11: 0x00000001013389e4 servo`std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,bool>(data=0x0000000122ff6670) + 292 at panicking.rs:460
    frame #12: 0x00000001058ba32b servo`panic_unwind::__rust_maybe_catch_panic + 27 at lib.rs:98
    frame #13: 0x000000010101de60 servo`std::panicking::try<bool,std::panic::AssertUnwindSafe<closure>>(f=AssertUnwindSafe<closure> at 0x0000000122ff6630) + 320 at panicking.rs:436
    frame #14: 0x0000000100f108f7 servo`std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,bool>(f=AssertUnwindSafe<closure> at 0x0000000122ff6778) + 103 at panic.rs:361
    frame #15: 0x0000000100b6aacd servo`js::panic::wrap_panic<std::panic::AssertUnwindSafe<closure>,bool>(function=AssertUnwindSafe<closure> at 0x0000000122ff67f0, generic_return_type=false) + 173 at panic.rs:22
    frame #16: 0x00000001024615d2 servo`script::dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementBinding::set_media(cx=0x0000000111822600, obj=Handle<*mut js::jsapi::JSObject> at 0x0000000122ff68c8, this=0x00000001234e0700, args=JSJitSetterCallArgs at 0x0000000122ff68e0) + 130 at mod.rs:165
    frame #17: 0x0000000103c6d79b servo`CallJitSetterOp(info=0x000000010716daa0, cx=0x0000000111822600, thisObj=JS::HandleObject at 0x0000000122ff69d8, specializedThis=0x00000001234e0700, argc=1, vp=0x0000000122ff7198) + 235 at jsglue.cpp:463
    frame #18: 0x0000000101e0ca64 servo`script::dom::bindings::utils::call_setter(info=0x000000010716daa0, cx=0x0000000111822600, handle=Handle<*mut js::jsapi::JSObject> at 0x0000000122ff6a30, this=0x00000001234e0700, argc=1, vp=0x0000000122ff7198) + 196 at utils.rs:480
    frame #19: 0x0000000101e0c781 servo`script::dom::bindings::utils::generic_call(cx=0x0000000111822600, argc=1, vp=0x0000000122ff7198, is_lenient=false, call=0x0000000101e0c9a0) + 3169 at utils.rs:446
    frame #20: 0x0000000101e0cb92 servo`script::dom::bindings::utils::generic_setter(cx=0x0000000111822600, argc=1, vp=0x0000000122ff7198) + 66 at utils.rs:492
    frame #21: 0x00000001040fbe86 servo`js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) [inlined] js::CallJSNative(native=<unavailable>)(JSContext*, unsigned int, JS::Value*), JS::CallArgs const&) + 226 at jscntxtinlines.h:232
    frame #22: 0x00000001040fbda4 servo`js::InternalCallOrConstruct(cx=0x0000000111822600, args=0x0000000122ff7168, construct=<unavailable>) + 692 at Interpreter.cpp:453
    frame #23: 0x00000001040fcb2e servo`js::CallSetter(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::Handle<JS::Value>) [inlined] js::Call(cx=0x0000000111822600, root=0x0000000113811e60, args=0x0000000122ff71a8) + 37 at Interpreter.cpp:517
    frame #24: 0x00000001040fcb09 servo`js::CallSetter(cx=0x0000000111822600, thisv=<unavailable>, setter=<unavailable>, v=<unavailable>) + 201 at Interpreter.cpp:644
    frame #25: 0x0000000104116d15 servo`js::NativeSetProperty(JSContext*, JS::Handle<js::NativeObject*>, JS::Handle<jsid>, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::QualifiedBool, JS::ObjectOpResult&) [inlined] JS::Handle<JS::Value>::Handle<JS::Value>(root=0x0000000113811e60, root=0x0000000113811e40, root=0x0000000113811e28, dummy=<unavailable>, dummy=<unavailable>, dummy=<unavailable>) + 153 at NativeObject.cpp:2364
    frame #26: 0x0000000104116c7c servo`js::NativeSetProperty(cx=<unavailable>, qualified=<unavailable>, result=<unavailable>, obj=<unavailable>, id=<unavailable>, value=<unavailable>, receiver=<unavailable>) + 1404 at NativeObject.cpp:2399
    frame #27: 0x00000001040ef3e5 servo`Interpret(JSContext*, js::RunState&) [inlined] js::SetProperty(cx=<unavailable>, root=0x0000000113811e28, dummy=<unavailable>, result=0xffffffffffffffff) + 42181 at NativeObject.h:1498
    frame #28: 0x00000001040ef3dd servo`Interpret(JSContext*, js::RunState&) [inlined] SetPropertyOperation(this=0x0000000111822600) at Interpreter.cpp:256
    frame #29: 0x00000001040ef3dd servo`Interpret(cx=<unavailable>, state=<unavailable>) + 42173 at Interpreter.cpp:2666
    frame #30: 0x00000001040e4eeb servo`js::RunScript(cx=0x0000000111822600, state=0x0000000122ff7ca0) + 411 at Interpreter.cpp:399
    frame #31: 0x00000001040fc16e servo`js::InternalCallOrConstruct(cx=0x0000000111822600, args=<unavailable>, construct=<unavailable>) + 1662 at Interpreter.cpp:471
    frame #32: 0x00000001040fc2d6 servo`js::Call(cx=<unavailable>, args=0x0000000122ff7d70, fval=<unavailable>, thisv=<unavailable>, rval=<unavailable>) + 38 at Interpreter.cpp:517
    frame #33: 0x0000000103fc25cf servo`JS_CallFunctionValue(cx=0x0000000111822600, args=<unavailable>, obj=<unavailable>, fval=<unavailable>, rval=<unavailable>) + 735 at jsapi.cpp:2781
    frame #34: 0x000000010237cdad servo`script::dom::bindings::codegen::Bindings::EventListenerBinding::{{impl}}::HandleEvent(self=0x0000000123418760, cx=0x0000000111822600, aThisObj=Handle<*mut js::jsapi::JSObject> at 0x0000000122ff7f90, event=0x00000001194583c0) + 2877 at mod.rs:165
    frame #35: 0x000000010237c211 servo`script::dom::bindings::codegen::Bindings::EventListenerBinding::{{impl}}::HandleEvent_<script::dom::eventtarget::EventTarget>(self=0x0000000123418760, thisObj=0x00000001234e0700, event=0x00000001194583c0, aExceptionHandling=Report) + 641 at mod.rs:165
    frame #36: 0x0000000101ecd23e servo`script::dom::eventtarget::{{impl}}::call_or_handle_event<script::dom::eventtarget::EventTarget>(self=0x000000011942cee0, object=0x00000001234e0700, event=0x00000001194583c0, exception_handle=Report) + 510 at eventtarget.rs:152
    frame #37: 0x0000000101ec5390 servo`script::dom::eventdispatcher::handle_event(window=Option<&script::dom::window::Window> at 0x0000000122ff8e90, listener=0x000000011942cee0, current_target=0x00000001234e0700, event=0x00000001194583c0) + 224 at eventdispatcher.rs:45
    frame #38: 0x0000000101ec6d2c servo`script::dom::eventdispatcher::inner_invoke(window=Option<&script::dom::window::Window> at 0x0000000122ff8fa8, object=0x00000001234e0700, event=0x00000001194583c0, listeners=&[script::dom::eventtarget::CompiledEventListener] at 0x0000000122ff8fc0) + 236 at eventdispatcher.rs:213
    frame #39: 0x0000000101ec6bd3 servo`script::dom::eventdispatcher::invoke(window=Option<&script::dom::window::Window> at 0x0000000122ff90a8, object=0x00000001234e0700, event=0x00000001194583c0, specific_listener_phase=Option<script::dom::eventtarget::ListenerPhase> at 0x0000000122ff90c0) + 419 at eventdispatcher.rs:188
    frame #40: 0x0000000101ec5908 servo`script::dom::eventdispatcher::dispatch_to_listeners(event=0x00000001194583c0, target=0x00000001234e0700, event_path=&[&script::dom::eventtarget::EventTarget] at 0x0000000122ff91e0) + 1272 at eventdispatcher.rs:82
    frame #41: 0x0000000101ec6623 servo`script::dom::eventdispatcher::dispatch_event(target=0x00000001234e0700, target_override=Option<&script::dom::eventtarget::EventTarget> at 0x0000000122ff9578, event=0x00000001194583c0) + 2595 at eventdispatcher.rs:156
    frame #42: 0x0000000101ecede9 servo`script::dom::eventtarget::{{impl}}::dispatch_event(self=0x00000001234e0700, event=0x00000001194583c0) + 57 at eventtarget.rs:307
    frame #43: 0x0000000101ec4dcb servo`script::dom::event::{{impl}}::fire(self=0x00000001194583c0, target=0x00000001234e0700) + 59 at event.rs:348
    frame #44: 0x0000000101ed22b2 servo`script::dom::eventtarget::{{impl}}::fire_event_with_params(self=0x00000001234e0700, name=Atom<servo_atoms::AtomStaticSet> at 0x0000000122ff9920, bubbles=DoesNotBubble, cancelable=NotCancelable) + 274 at eventtarget.rs:540
    frame #45: 0x0000000101ed1ff8 servo`script::dom::eventtarget::{{impl}}::fire_event(self=0x00000001234e0700, name=Atom<servo_atoms::AtomStaticSet> at 0x0000000122ff99c0) + 88 at eventtarget.rs:507
    frame #46: 0x00000001020b9684 servo`script::stylesheet_loader::{{impl}}::process_response_eof(self=0x00000001234672a0, status=Result<(), net_traits::NetworkError> at 0x0000000122ff9c30) + 3492 at stylesheet_loader.rs:181
    frame #47: 0x0000000101ae427c servo`net_traits::{{impl}}::process<script::stylesheet_loader::StylesheetContext>(self=FetchResponseMsg at 0x0000000122ffa510, listener=0x00000001234672a0) + 716 at lib.rs:239
    frame #48: 0x000000010207ef88 servo`script::network_listener::{{impl}}::handler<net_traits::FetchResponseMsg,script::stylesheet_loader::StylesheetContext>(self=0x000000011943b740) + 408 at network_listener.rs:63
    frame #49: 0x000000010208993d servo`script::script_thread::{{impl}}::handler<script::network_listener::ListenerRunnable<net_traits::FetchResponseMsg, script::stylesheet_loader::StylesheetContext>>(self=0x000000011940c170) + 29 at script_thread.rs:219
    frame #50: 0x00000001020978e4 servo`script::script_thread::{{impl}}::handle_msg_from_script(self=0x0000000122ffece8, msg=MainThreadScriptMsg at 0x0000000122ffb2b8) + 916 at script_thread.rs:1036
    frame #51: 0x0000000102093e9f servo`script::script_thread::{{impl}}::handle_msgs::{{closure}} + 383 at script_thread.rs:862
    frame #52: 0x00000001020944e2 servo`script::script_thread::{{impl}}::profile_event<closure,core::option::Option<bool>>(self=0x0000000122ffece8, category=NetworkEvent, f=closure at 0x0000000122ffbbe0) + 290 at script_thread.rs:956
    frame #53: 0x000000010209280b servo`script::script_thread::{{impl}}::handle_msgs(self=0x0000000122ffece8) + 6555 at script_thread.rs:855
    frame #54: 0x0000000102090d56 servo`script::script_thread::{{impl}}::start(self=0x0000000122ffece8) + 326 at script_thread.rs:713
    frame #55: 0x000000010208cf55 servo`script::script_thread::{{impl}}::create::{{closure}}::{{closure}} + 37 at script_thread.rs:556
    frame #56: 0x0000000100807787 servo`profile_traits::mem::{{impl}}::run_with_memory_reporting<closure,fn(self=0x0000000122ffecb0, f=closure at 0x0000000122ffe900, reporter_name=String at 0x0000000122ffe910, channel_for_reporter=Sender<script::script_thread::MainThreadScriptMsg> at 0x0000000122ffe928, msg=0x0000000122ffe8e0) -> script::script_runtime::CommonScriptMsg,script::script_runtime::CommonScriptMsg,std::sync::mpsc::Sender<script::script_thread::MainThreadScriptMsg>> + 743 at mem.rs:63
    frame #57: 0x000000010208d605 servo`script::script_thread::{{impl}}::create::{{closure}} + 1637 at script_thread.rs:555
    frame #58: 0x0000000101c6c67b servo`std::panic::{{impl}}::call_once<(self=AssertUnwindSafe<closure> at 0x0000000122fff2d8, _args=<unavailable>),closure> + 155 at panic.rs:296
    frame #59: 0x00000001012f51da servo`std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,(data=0x0000000122fffee8)> + 410 at panicking.rs:460
    frame #60: 0x00000001058ba32b servo`panic_unwind::__rust_maybe_catch_panic + 27 at lib.rs:98
    frame #61: 0x0000000101053f04 servo`std::panicking::try<(f=AssertUnwindSafe<closure> at 0x0000000122fffc98),std::panic::AssertUnwindSafe<closure>> + 292 at panicking.rs:436
    frame #62: 0x0000000100f5a1b5 servo`std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,(f=AssertUnwindSafe<closure> at 0x0000000123000530)> + 165 at panic.rs:361
    frame #63: 0x0000000100f77cfc servo`std::thread::{{impl}}::spawn::{{closure}}<closure,()> + 396 at mod.rs:357
    frame #64: 0x000000010190e423 servo`alloc::boxed::{{impl}}::call_box<(self=0x000000011dc73000, args=<unavailable>),closure> + 83 at boxed.rs:605
    frame #65: 0x00000001058b8395 servo`std::sys::imp::thread::{{impl}}::new::thread_start [inlined] alloc::boxed::{{impl}}::call_once<(),()> + 37 at boxed.rs:615
    frame #66: 0x00000001058b838f servo`std::sys::imp::thread::{{impl}}::new::thread_start [inlined] std::sys_common::thread::start_thread + 15 at thread.rs:21
    frame #67: 0x00000001058b8380 servo`std::sys::imp::thread::{{impl}}::new::thread_start + 16 at thread.rs:84
    frame #68: 0x00007fff8e409899 libsystem_pthread.dylib`_pthread_body + 138
    frame #69: 0x00007fff8e40972a libsystem_pthread.dylib`_pthread_start + 137
    frame #70: 0x00007fff8e40dfc9 libsystem_pthread.dylib`thread_start + 13

This ties in the work in #14930. We probably want to null out HTMLLinkElement's stylesheet field before starting a load to avoid this assertion.

@jdm jdm changed the title assertion failed: self.stylesheet.borrow().is_none() <link> elements need to clear any previous stylesheet before loading a new one Jan 18, 2017
@jdm jdm added the E-easy label Jan 18, 2017
@highfive
Copy link

@highfive highfive commented Jan 18, 2017

Please make a comment here if you intend to work on this issue. Thank you!

@SwagColoredKitteh
Copy link
Contributor

@SwagColoredKitteh SwagColoredKitteh commented Jan 19, 2017

Can I take this one?

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Jan 19, 2017

@SwagColoredKitteh Sure thing! Ask us any questions here or at #servo in irc.mozilla.org if you run into any problems!

@KiChjang KiChjang added the C-assigned label Jan 19, 2017
SwagColoredKitteh added a commit to SwagColoredKitteh/servo that referenced this issue Jan 23, 2017
SwagColoredKitteh added a commit to SwagColoredKitteh/servo that referenced this issue Jan 24, 2017
SwagColoredKitteh added a commit to SwagColoredKitteh/servo that referenced this issue Jan 24, 2017
SwagColoredKitteh added a commit to SwagColoredKitteh/servo that referenced this issue Jan 24, 2017
bors-servo added a commit that referenced this issue Jan 24, 2017
Prevent crashing when a link tag has two or more in-flight requests (fix for issue #15101)

<!-- Please describe your changes on the following line: -->
The `HTMLLinkElement::set_stylesheet` function now checks whether there already is a stylesheet, and if there is, calls `Document::invalidate_stylesheets` after modifying `self.stylesheet`.

This PR also includes a minimal WPT that causes the panic.

This is fundamentally a timing issue, so while this fix prevents the crash, it does not fix the underlying issue. Making a &lt;link&gt; element send a second request before the first can finish and then getting the two stylesheet responses out-of-order will apply the wrong stylesheet, as demonstrated with https://gist.github.com/SwagColoredKitteh/2c24c7fac635445042eda4a30e10420e.

r? @emilio

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15101 (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15145)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.