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

Ensure documents and fetch cancellers drop #24047

Conversation

@gterzian
Copy link
Member

gterzian commented Aug 25, 2019

Related to #23905 (comment) and #23905 (comment)


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because ___

This change is Reviewable

@highfive
Copy link

highfive commented Aug 25, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/script_thread.rs, components/script/dom/document.rs, components/script/dom/window.rs, components/script/document_loader.rs
  • @KiChjang: components/script/script_thread.rs, components/script/dom/document.rs, components/script/dom/window.rs, components/script/document_loader.rs
@highfive
Copy link

highfive commented Aug 25, 2019

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify script code, but no tests are modified. Please consider adding a test!
@gterzian
Copy link
Member Author

gterzian commented Aug 25, 2019

@gterzian gterzian force-pushed the gterzian:ensure_documents_and_fetch_cancellers_drop branch from aba3e07 to cb64339 Aug 25, 2019
@gterzian
Copy link
Member Author

gterzian commented Aug 25, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2019

Trying commit cb64339 with merge f6d3eaf...

bors-servo added a commit that referenced this pull request Aug 25, 2019
…_drop, r=<try>

Ensure documents and fetch cancellers drop

<!-- Please describe your changes on the following line: -->

Related to #23905 (comment) and #23905 (comment)

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

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

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/24047)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2019

💔 Test failed - linux-rel-css

@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Aug 25, 2019

Opened new PR for upstreamable changes.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#18661.

@gterzian gterzian force-pushed the gterzian:ensure_documents_and_fetch_cancellers_drop branch from daa1bc3 to c823074 Aug 25, 2019
@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Aug 25, 2019

No upstreamable changes; closed existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#18661.

@gterzian
Copy link
Member Author

gterzian commented Aug 25, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2019

Trying commit c823074 with merge 7cccf25...

bors-servo added a commit that referenced this pull request Aug 25, 2019
…_drop, r=<try>

Ensure documents and fetch cancellers drop

<!-- Please describe your changes on the following line: -->

Related to #23905 (comment) and #23905 (comment)

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

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

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/24047)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2019

💔 Test failed - linux-rel-css

@gterzian gterzian force-pushed the gterzian:ensure_documents_and_fetch_cancellers_drop branch 5 times, most recently from 7381c21 to d4b0541 Aug 25, 2019
@gterzian
Copy link
Member Author

gterzian commented Aug 25, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2019

Trying commit d4b0541 with merge f1d188e...

@gterzian
Copy link
Member Author

gterzian commented Aug 26, 2019

@bors-servo try=wpt (fixed the double borrow on Gc, since get_cx will borrow the current-state, you can't call it while borrowing it).

@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2019

Trying commit 1ec46e2 with merge 01764ac...

bors-servo added a commit that referenced this pull request Aug 26, 2019
…_drop, r=<try>

Ensure documents and fetch cancellers drop

<!-- Please describe your changes on the following line: -->

Related to #23905 (comment) and #23905 (comment)

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

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

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/24047)
<!-- Reviewable:end -->
@gterzian
Copy link
Member Author

gterzian commented Aug 26, 2019

Ok so this one still crashes:

{
    "status": "CRASH", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": null, 
    "test": "/html/cross-origin-embedder-policy/blob.https.html", 
    "line": 348518, 
    "action": "test_result", 
    "expected": "OK"
}

and I think the right thing might be to mark as is a CRASH expectation, and fix it as part of #24052

@jdm what do you think?

@jdm
Copy link
Member

jdm commented Aug 26, 2019

That depends on what the rest of the crash output looks like.

@gterzian
Copy link
Member Author

gterzian commented Aug 26, 2019

@jdm

▶ CRASH [expected OK] /html/cross-origin-embedder-policy/blob.https.html
  │ 
  │ 
  │ 
  │ 
  │ 
  │ (servo:22597): GStreamer-WARNING **: External plugin loader failed. This most likely means that the plugin loader helper binary was not found or could not be run. You might need to set the GST_PLUGIN_SCANNER environment variable if your setup is unusual. This should normally not be required though.
  │ 0:00:00.015676230 22597 0x5566d88660a0 WARN      GST_PLUGIN_LOADING gstplugin.c:793:_priv_gst_plugin_load_file_for_registry: module_open failed: libasound.so.2: cannot open shared object file: No such file or directory
  │ 
  │ (servo:22597): GStreamer-WARNING **: Failed to load plugin '/home/servo/gst/lib/gstreamer-1.0/libgstalsa.so': libasound.so.2: cannot open shared object file: No such file or directory
  │ 0:00:00.015946639 22597 0x5566d88660a0 WARN      GST_PLUGIN_LOADING gstplugin.c:793:_priv_gst_plugin_load_file_for_registry: module_open failed: libmms.so.0: cannot open shared object file: No such file or directory
  │ 
  │ (servo:22597): GStreamer-WARNING **: Failed to load plugin '/home/servo/gst/lib/gstreamer-1.0/libgstmms.so': libmms.so.0: cannot open shared object file: No such file or directory
  │ 0:00:00.016083983 22597 0x5566d88660a0 WARN      GST_PLUGIN_LOADING gstplugin.c:793:_priv_gst_plugin_load_file_for_registry: module_open failed: libfaad.so.2: cannot open shared object file: No such file or directory
  │ 
  │ (servo:22597): GStreamer-WARNING **: Failed to load plugin '/home/servo/gst/lib/gstreamer-1.0/libgstfaad.so': libfaad.so.2: cannot open shared object file: No such file or directory
  │ assertion failed: !global.is_null() (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(1) }, at components/script/dom/globalscope.rs:839)
  │ stack backtrace:
  │    0: servo::main::{{closure}}::h1afb3685c80975ba (0x5566d1b98c9c)
  │    1: std::panicking::rust_panic_with_hook::h185be11cf56dd6c5 (0x5566d4e0cb5b)
  │              at src/libstd/panicking.rs:481
  │    2: std::panicking::begin_panic::h01612bde116ad71c (0x5566d2e5fac4)
  │    3: script::dom::globalscope::GlobalScope::from_object::hbed3f7de21dcd592 (0x5566d293860f)
  │    4: <script::dom::blob::Blob as core::ops::drop::Drop>::drop::h3fe5d138b4c51e97 (0x5566d2da1c74)
  │    5: _ZN4core3ptr18real_drop_in_place17he0a0bf789355b2c6E.llvm.11484758652022629621 (0x5566d264eb0c)
  │    6: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h1d1bbe56e1a03ee2 (0x5566d240f8d8)
  │    7: __rust_maybe_catch_panic (0x5566d4e167b9)
  │              at src/libpanic_unwind/lib.rs:80
  │    8: script::dom::bindings::codegen::Bindings::BlobBinding::BlobBinding::_finalize::h69419e4df336f73a (0x5566d2a94cd0)
  │    9: _ZNK2js5Class10doFinalizeEPNS_6FreeOpEP8JSObject (0x5566d339cd70)
  │              at /home/servo/buildbot/slave/linux-rel-wpt/build/target/release/build/mozjs_sys-b335846056e5ad1a/out/dist/include/js/Class.h:872
  │       _ZN8JSObject8finalizeEPN2js6FreeOpE
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/vm/JSObject-inl.h:83
  │       _ZN2js2gc5Arena8finalizeI8JSObjectEEmPNS_6FreeOpENS0_9AllocKindEm
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:591
  │   10: _ZL19FinalizeTypedArenasI8JSObjectEbPN2js6FreeOpEPPNS1_2gc5ArenaERNS4_15SortedArenaListENS4_9AllocKindERNS1_11SliceBudgetENS4_10ArenaLists14KeepArenasEnumE (0x5566d339ca72)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:651
  │   11: _ZL14FinalizeArenasPN2js6FreeOpEPPNS_2gc5ArenaERNS2_15SortedArenaListENS2_9AllocKindERNS_11SliceBudgetENS2_10ArenaLists14KeepArenasEnumE (0x5566d337fbe2)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:0
  │   12: _ZN2js2gc10ArenaLists18foregroundFinalizeEPNS_6FreeOpENS0_9AllocKindERNS_11SliceBudgetERNS0_15SortedArenaListE (0x5566d338b603)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:5820
  │   13: _ZN2js2gc9GCRuntime17finalizeAllocKindEPNS_6FreeOpERNS_11SliceBudgetEPN2JS4ZoneENS0_9AllocKindE (0x5566d338c258)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:6110
  │   14: _ZN11sweepaction18SweepActionForEachI13ContainerIterIN7mozilla7EnumSetIN2js2gc9AllocKindEjEEES7_JPNS5_9GCRuntimeEPNS4_6FreeOpERNS4_11SliceBudgetEPN2JS4ZoneEEE3runESA_SC_SE_SH_ (0x5566d33a56eb)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:6327
  │   15: _ZN11sweepaction19SweepActionSequenceIJPN2js2gc9GCRuntimeEPNS1_6FreeOpERNS1_11SliceBudgetEPN2JS4ZoneEEE3runES4_S6_S8_SB_ (0x5566d33a58f4)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:6296
  │   16: _ZN11sweepaction18SweepActionForEachIN2js2gc19SweepGroupZonesIterEP9JSRuntimeJPNS2_9GCRuntimeEPNS1_6FreeOpERNS1_11SliceBudgetEEE3runES7_S9_SB_ (0x5566d33a5d95)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/PrivateIterators-inl.h:0
  │   17: _ZN11sweepaction19SweepActionSequenceIJPN2js2gc9GCRuntimeEPNS1_6FreeOpERNS1_11SliceBudgetEEE3runES4_S6_S8_ (0x5566d33a5fd1)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:6296
  │   18: _ZN11sweepaction20SweepActionRepeatForIN2js2gc15SweepGroupsIterEP9JSRuntimeJPNS2_9GCRuntimeEPNS1_6FreeOpERNS1_11SliceBudgetEEE3runES7_S9_SB_ (0x5566d33a6475)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:6356
  │   19: _ZN2js2gc9GCRuntime19performSweepActionsERNS_11SliceBudgetE (0x5566d338c79d)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:6528
  │   20: _ZN2js2gc9GCRuntime16incrementalSliceERNS_11SliceBudgetEN2JS8GCReasonERNS0_13AutoGCSessionE (0x5566d338e1ec)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:7049
  │   21: _ZN2js2gc9GCRuntime7gcCycleEbNS_11SliceBudgetEN2JS8GCReasonE (0x5566d338f2ff)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:7398
  │   22: _ZN2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8GCReasonE (0x5566d338fd4f)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:7569
  │   23: _ZN2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8GCReasonE (0x5566d33753cc)
  │              at /home/servo/.cargo/git/checkouts/mozjs-fc2b6454b6e5027a/8164c52/mozjs/js/src/gc/GC.cpp:7657
  │   24: script::dom::window::Window::clear_js_runtime::hede5f42c29e243a8 (0x5566d22f6e5c)
  │   25: script::script_thread::ScriptThread::handle_exit_pipeline_msg::h15b13e30d95a8b68 (0x5566d29a93db)
  │   26: script::script_thread::ScriptThread::handle_msg_from_constellation::h979c212ec4775fd7 (0x5566d299ae23)
  │   27: script::script_thread::ScriptThread::handle_msgs::{{closure}}::h02dd7eae7e22f2a5 (0x5566d2995fb6)
  │   28: _ZN6script13script_thread12ScriptThread11handle_msgs17he1804ce486e0062fE.llvm.9770716575427483833 (0x5566d29901dd)
  │   29: script::script_thread::ScriptThread::start::h276b7c1d3f1301ef (0x5566d298a397)
  │   30: profile_traits::mem::ProfilerChan::run_with_memory_reporting::h89a11c80421d28bc (0x5566d2a1d35c)
  │   31: std::sys_common::backtrace::__rust_begin_short_backtrace::hc1e09c16ff7f502b (0x5566d2140c78)
  │   32: _ZN3std9panicking3try7do_call17h91c92f576415b501E.llvm.2134618637238848137 (0x5566d2e89963)
  │   33: __rust_maybe_catch_panic (0x5566d4e167b9)
  │              at src/libpanic_unwind/lib.rs:80
  │   34: core::ops::function::FnOnce::call_once{{vtable.shim}}::h9a16ee729ab39237 (0x5566d2338262)
  │   35: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h007a3b027456a6a9 (0x5566d4dfb1ce)
  │              at /rustc/9eae1fc0ea9b00341b8fe191582c4decb5cb86a3/src/liballoc/boxed.rs:922
  │   36: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h3b5231ca6bdd7b3c (0x5566d4e15aff)
  │              at /rustc/9eae1fc0ea9b00341b8fe191582c4decb5cb86a3/src/liballoc/boxed.rs:922
  │       std::sys_common::thread::start_thread::hb32caa9dd2aeb43f
  │              at src/libstd/sys_common/thread.rs:13
  │       std::sys::unix::thread::Thread::new::thread_start::ha037b97c352bfa07
  │              at src/libstd/sys/unix/thread.rs:79
  │   37: start_thread (0x7f796ca3c6b9)
  │   38: clone (0x7f796b2d741c)
  │   39: <unknown> (0x0)
  │ [2019-08-26T16:44:41Z ERROR servo] assertion failed: !global.is_null()
  └ Pipeline failed in hard-fail mode.  Crashing!
@jdm
Copy link
Member

jdm commented Aug 26, 2019

Ok, that test is quite new, and I don't see a clear relationship to these changes that would affect its behaviour. Changing its expected result to CRASH seems reasonable to me.

@gterzian
Copy link
Member Author

gterzian commented Aug 26, 2019

I don't see a clear relationship to these changes that would affect its behaviour

Since without these changes we would leak the globalscope, I can imagine the crash is a result of the global scope dropping before the blob, due to the current changes. The test calls frame.remove, which closes the pipeline and drops the global of the iframe(unless script keeps a reference to the window of the iframe).

The fix for this is to run the clean-up steps for the blob not when it drops, but when the document is is associated is unloaded, which ensures the global is alive when the blob clean-up steps are run(and it the specced behavior).

By the way I thought you had opened #24052 due to the test result in this PR. Did you see the crash elsewhere? In that case it might not be related...

@gterzian gterzian force-pushed the gterzian:ensure_documents_and_fetch_cancellers_drop branch from 1ec46e2 to fe6148c Aug 26, 2019
@jdm
Copy link
Member

jdm commented Aug 26, 2019

I may indeed have opened that issue due to seeing the test failure in this PR.

@gterzian gterzian force-pushed the gterzian:ensure_documents_and_fetch_cancellers_drop branch 3 times, most recently from 0f940a1 to 9009bef Aug 26, 2019
Copy link
Member

asajeffrey left a comment

I'm kind of queasy about this approach, we're adding a lot of potential panics, and I'm not sure what the semantics of zombie windows is meant to be.

/// A window without a browsing-context,
/// keeping only its associated document, since it should always be kept.
/// See https://html.spec.whatwg.org/multipage/#concept-document-window
Zombie(MutNullableDom<Document>),

This comment has been minimized.

@asajeffrey

asajeffrey Aug 26, 2019

Member

Not sure if we need to keep the document, if this Window is unreachable from script.

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

I added the document to the zombie state, because without it this test started failing: /html/browsers/the-window-object/document-attribute.window.html. The reason for the failure is that if you do frame.remove(); the browsing-context is discarded, and in servo the pipeline is closed, however the window/document are still potentially reachable from script.

Alive,
Zombie, // Pipeline is closed, but the window hasn't been GCed yet.
/// A window with a browsing-context.
Alive(WindowStateData),

This comment has been minimized.

@asajeffrey

asajeffrey Aug 26, 2019

Member

Is there a spec name for this? Discarded? Perhaps Reachable vs Unreachable? Or ReachableFromJS?

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

We could go for BrowsingContextDiscarded and WithBrowsingContext, because the switch really occurs as part of https://html.spec.whatwg.org/multipage/window-object.html#garbage-collection-and-browsing-contexts and the window and document could still be reachable from script afterwards.

@@ -137,10 +137,15 @@ use webrender_api::{DocumentId, ExternalScrollId, RenderApiSender};
use webvr_traits::WebVRMsg;

/// Current state of the window object
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
#[derive(JSTraceable, MallocSizeOf)]
#[must_root]
enum WindowState {

This comment has been minimized.

@asajeffrey

asajeffrey Aug 26, 2019

Member

Bikeshed this name?

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

Sure, into what?

@@ -377,7 +408,12 @@ impl Window {

#[allow(unsafe_code)]
pub fn get_cx(&self) -> JSContext {
unsafe { JSContext::from_ptr(self.js_runtime.borrow().as_ref().unwrap().cx()) }
match &*self.current_state.borrow_mut() {
WindowState::Zombie(_) => unreachable!("Window should be alive when get_cx is called"),

This comment has been minimized.

@asajeffrey

asajeffrey Aug 26, 2019

Member

unreachable! is for code that really really is unreachable, e.g. the method that triggers it is private. It's not intended for this sort of thing where it should really be a panic!

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

Ok, I'll change it.

// In the Zombie case, create an object for script, but don't store it.
// Usage of the object should throw security errors,
// since there is no associated document or browsing-context.
WindowState::Zombie(_) => History::new(self),

This comment has been minimized.

@asajeffrey

asajeffrey Aug 26, 2019

Member

Not sure this is the right behaviour, aren't zombie windows meant to be unreachable from script?

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

They can be reachable, as exemplified by at least one test at /html/browsers/the-window-object/document-attribute.window.html.

The history interface throws a security error if used from a not fully active document(which would include one whose BC has been discarded), see https://html.spec.whatwg.org/multipage/history.html#the-history-interface:fully-active-2

// In the Zombie case, create an object for script, but don't store it.
// Usage of the object should throw security errors,
// since there is no associated document or browsing-context.
WindowState::Zombie(_) => CustomElementRegistry::new(self),

This comment has been minimized.

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

The comment here looks wrong, since it seems the registry does not have a concept of throwing errors when used after the BC as been discarded. However it could still be reachable from script even in the zombie state.

The idea is that if we still make the interface available to script, but don't store it, we can be sure the Rust part isn't keeping the window alive for longer than it would be used from script, including via potential references to the window from these various interfaces.

Some of these interfaces take the discarding of browsing context into account, and some do not, and I wonder whether they all implicitly are only usable when the browsing-context has not been discarded.

// In the Zombie case, create an object for script, but don't store it.
// Usage of the object should throw security errors,
// since there is no associated document or browsing-context.
WindowState::Zombie(_) => Location::new(self),

This comment has been minimized.

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

The location interface uses a concept of a relevant-document, and sometimes throws a security error or simply returns when the interface is used when the relevant document is null(and the "relevant document" is the active doc of the BC, so null in zombie state).

nodes.push(Dom::from_ref(&*node));
match &*self.current_state.borrow_mut() {
WindowState::Zombie(_) => {
unreachable!("Window should be alive when force_reflow is called")

This comment has been minimized.

@asajeffrey

asajeffrey Aug 26, 2019

Member

Are we really sure that there's no race condition between script, layout, the compositor, etc that can trigger this?

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

I'm not sure, and I think a panic is probably the right way to become aware of these. I do think any reflow after the browsing-context has been discarded, and the pipeline closed(and the layout thread exited), is likely to be wrong and would require fixing.

This comment has been minimized.

@gterzian

gterzian Aug 27, 2019

Author Member

Also, a reflow on a zombie window would already panic on the send to the layout chan above, since the pipeline would already have been closed.

Such a panic due to reflow on a closed pipeline has already been noted, for example in #19170

@gterzian gterzian force-pushed the gterzian:ensure_documents_and_fetch_cancellers_drop branch from 9009bef to 581a5a2 Aug 27, 2019
@gterzian
Copy link
Member Author

gterzian commented Aug 27, 2019

I'll see if I can find which MutNullableDom was keeping the window alive, so that we can consider just dealing with that more precisely.

@gterzian gterzian mentioned this pull request Aug 27, 2019
0 of 5 tasks complete
@gterzian
Copy link
Member Author

gterzian commented Aug 27, 2019

@jdm @asajeffrey There is a minimalist alternative open at #24072 It does the trick, although I can't make out why Performance would prevent the document/window/globalscope from dropping.

bors-servo added a commit that referenced this pull request Aug 27, 2019
Ensure documents drop when a pipeline exits

<!-- Please describe your changes on the following line: -->

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

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

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/24072)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Aug 28, 2019
Ensure documents drop when a pipeline exits

<!-- Please describe your changes on the following line: -->

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

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

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/24072)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Aug 28, 2019
Ensure documents drop when a pipeline exits

<!-- Please describe your changes on the following line: -->

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

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

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/24072)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 28, 2019

The latest upstream changes (presumably #24072) made this pull request unmergeable. Please resolve the merge conflicts.

@gterzian
Copy link
Member Author

gterzian commented Aug 29, 2019

In favor of #24072

@gterzian gterzian closed this Aug 29, 2019
@gterzian gterzian deleted the gterzian:ensure_documents_and_fetch_cancellers_drop branch Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

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