Skip to content

Script: ensure child JS runtimes are dropped before parent#30896

Merged
mrobinson merged 5 commits intoservo:mainfrom
gterzian:master
Jan 4, 2024
Merged

Script: ensure child JS runtimes are dropped before parent#30896
mrobinson merged 5 commits intoservo:mainfrom
gterzian:master

Conversation

@gterzian
Copy link
Copy Markdown
Member

@gterzian gterzian commented Dec 20, 2023

Remove the annoying This runtime still has live children. that keeps showing up.

Many issues that contain that backtrace as opposed to the actual underlying problem:

FIX #30124
FIX #24168
FIX #25729
FIX #28357
FIX #26778

Marking them as fixed, because it appears to me that the original panic is already filed in other issues(i've pointed it out in each issue).


  • ./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 ___

@mrobinson
Copy link
Copy Markdown
Member

Looks like this is just failing due to a tidy issue. It should be fixed with ./mach fmt.

@gterzian
Copy link
Copy Markdown
Member Author

See #30124 (comment) for an exaplanation, and I think the conclusion is that every time script crashes, we drop the "top" runtime as part of clear_js_runtime_for_script_deallocation, which gives us another panic in case there are outstanding children.

See

/// In the event of thread panic, all data on the stack runs its destructor. However, there

Compare with the "clean" version which is followed on orderly shutdown of a pipepline:

window.clear_js_runtime();

@gterzian gterzian marked this pull request as ready for review December 27, 2023 09:07
@gterzian gterzian requested a review from mrobinson December 27, 2023 09:07
@gterzian gterzian marked this pull request as draft December 27, 2023 12:41
@gterzian gterzian removed the request for review from mrobinson December 27, 2023 12:41
@gterzian
Copy link
Copy Markdown
Member Author

Upon further investigation, this doesn't seem to fix the problem, so I'll investigate further...

@gterzian gterzian marked this pull request as ready for review December 28, 2023 03:59
@gterzian
Copy link
Copy Markdown
Member Author

Ok so this required different fixes, because each linked-to issues was actually hitting a different problem. All are covered now.

@mrobinson r?

@gterzian gterzian requested a review from mrobinson December 28, 2023 04:00
@gterzian gterzian changed the title Script: shutdown worker infra when deallocating script Script: ensure child JS runtime are dropped before parent Dec 28, 2023
@gterzian gterzian changed the title Script: ensure child JS runtime are dropped before parent Script: ensure child JS runtimes are dropped before parent Dec 28, 2023
@gterzian gterzian requested a review from sagudev December 29, 2023 07:36
Copy link
Copy Markdown
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense! My only question is whether we should use an object with a Drop impl that could replace the manual calls in the dedicated worker code?

@sagudev
Copy link
Copy Markdown
Member

sagudev commented Dec 29, 2023

This makes sense! My only question is whether we should use an object with a Drop impl that could replace the manual calls in the dedicated worker code?

std::mem::forget is safe and we might be relaying on drops too much already.

@jdm
Copy link
Copy Markdown
Member

jdm commented Dec 29, 2023

I'm not concerned about safety, just avoiding any other early return branches where the same fix should be applied but might be missed.

@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jan 2, 2024

use an object with a Drop impl that could replace the manual calls in the dedicated worker code?

It appears to not work for now,drop of the WorkerGlobalScope seems to not be called and the error comes back, so I've filed #30971

Have also added a manual branch to the ServiceWorkerGlobalScope, and also fixed an inconsistency when it came to calling enter_realm before executing the loaded worker script.

@sagudev sagudev self-requested a review January 2, 2024 15:51
@sagudev
Copy link
Copy Markdown
Member

sagudev commented Jan 2, 2024

note to self: use ./mach test-wpt tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.https.html to enter_realm

@sagudev sagudev added the T-full Do a full try run label Jan 3, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 3, 2024

🔨 Triggering try run (#7393899054) with platforms=linux,macos,windows and layout=undefined

@github-actions github-actions bot removed the T-full Do a full try run label Jan 3, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 3, 2024

Test results for linux-wpt-layout-2013 from try job (#7393899054):

Flaky unexpected result (16)
  • CRASH [expected OK] /_mozilla/mozilla/service-workers/service-worker-registration.https.html
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-with-non-reserved-words.html (#16216)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • OK /css/css-flexbox/text-as-flexitem-size-001.html (#28726)
    • FAIL [expected PASS] subtest: .flexbox > div 1 assert_equals:
      <div data-expected-width="70" data-expected-height="35">
      <p>xx xxx</p>
      <p>xx</p>
      </div>
      width expected 70 but got 46
    • FAIL [expected PASS] subtest: .flexbox > div 2 assert_equals:
      <div data-expected-width="50" data-expected-height="45">
      <p>xx xxx</p>
      <p>xx</p>
      </div>
      width expected 50 but got 46
    • FAIL [expected PASS] subtest: .flexbox > div 5 assert_equals:
      <div style="height: 30px" data-expected-width="70" data-expected-height="30">
      <p>xx xxx</p>
      <p>xx</p>
      </div>
      width expected 70 but got 46
    • FAIL [expected PASS] subtest: .flexbox > div 8 assert_equals:
      <div style="min-height: 40px" data-expected-width="70" data-expected-height="40">
      <p>xx xxx</p>
      <p>xx</p>
      </div>
      width expected 70 but got 46
    • FAIL [expected PASS] subtest: .flexbox > div 11 assert_equals:
      <div style="max-height: 20px" data-expected-width="70" data-expected-height="20">
      <p>xx xxx</p>
      <p>xx</p>
      </div>
      width expected 70 but got 46
  • OK /css/cssom-view/MediaQueryList-addListener-removeListener.html (#24569)
    • PASS [expected FAIL] subtest: listeners are called correct number of times
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html (#28691)
    • FAIL [expected PASS] subtest: load event does not fire on window.open('about:blank') assert_unreached: load should not be fired Reached unreachable code
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.html (#29056)
    • PASS [expected FAIL] subtest: Cross-origin navigation started from unload handler must be ignored
  • OK [expected FAIL] /html/infrastructure/urls/base-url/document-base-url-window-initiator-is-not-opener.https.window.html (#30970)
  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
  • OK /html/semantics/forms/form-submission-0/urlencoded2.window.html (#28687)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: single quote in filename (formdata event)
  • OK /html/semantics/forms/historical.html (#28568)
    • PASS [expected FAIL] subtest: <input name=isindex> should not be supported
  • TIMEOUT [expected OK] /html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.html (#26371)
    • TIMEOUT [expected FAIL] subtest: delayed handling: delaying handling rejected promise created from createImageBitmap will cause both events to fire Test timed out
  • OK [expected TIMEOUT] /webaudio/the-audio-api/the-audiocontext-interface/audiocontext-not-fully-active.html (#27664)
  • TIMEOUT [expected OK] /webmessaging/with-ports/018.html (#24485)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, javascript: Test timed out
  • OK [expected TIMEOUT] /webmessaging/without-ports/018.html (#24485)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, javascript:
  • OK /workers/WorkerGlobalScope-close.html (#23064)
    • PASS [expected FAIL] subtest: Test sending a message after closing.
Stable unexpected results that are known to be intermittent (17)
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-uniform-packing-restrictions.html (#28103)
    • NOTRUN [expected PASS] subtest: Overall test
  • OK /css/CSS2/linebox/inline-negative-margin-001.html (#23862)
    • PASS [expected FAIL] subtest: [data-expected-height] 1
    • PASS [expected FAIL] subtest: [data-expected-height] 2
    • FAIL [expected PASS] subtest: [data-expected-height] 4 assert_equals:
      <div class="w4" data-expected-height="10">123 <span style="margin-left: -4ch">123 </span></div>
      height expected 10 but got 20
  • PASS [expected TIMEOUT] /css/css-color/animation/opacity-animation-ending-correctly-001.html (#29215)
  • OK /css/cssom-view/scroll-behavior-smooth-navigation.html (#29564)
    • FAIL [expected PASS] subtest: Smooth scrolling while doing history navigation. assert_not_equals: Shouldn't be scrolled to top anymore. got disallowed value 0
  • TIMEOUT /fetch/metadata/generated/css-images.sub.tentative.html (#29047)
    • FAIL [expected PASS] subtest: border-image sec-fetch-site - Not sent to non-trustworthy same-origin destination assert_unreached: Reached unreachable code
    • TIMEOUT [expected PASS] subtest: background-image sec-fetch-site - HTTPS downgrade (header not sent) Test timed out
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html (#28681)
    • PASS [expected FAIL] subtest: load & pageshow events do not fire on contentWindow of <iframe> element created with src=''
    • PASS [expected FAIL] subtest: load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank'
  • TIMEOUT [expected OK] /html/browsers/the-window-object/open-close/creating_browsing_context_test_01.html (#29046)
    • TIMEOUT [expected PASS] subtest: first argument: absolute url Test timed out
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • FAIL [expected TIMEOUT] subtest: Area element should support autofocus assert_equals: expected Element node <area></area> but got Element node <body>
      <img src="/media/poster.png" usemap="#map">
      <map n...
  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html (#24066)
  • OK /html/semantics/forms/form-submission-0/text-plain.window.html (#28687)
    • FAIL [expected PASS] subtest: text/plain: \r\n in name (formdata event) assert_equals: expected "a\r\nb=c\r\n" but got ""
    • FAIL [expected PASS] subtest: text/plain: single quote in name (normal form) assert_equals: expected "a'b=c\r\n" but got ""
  • TIMEOUT /html/webappapis/scripting/events/compile-event-handler-settings-objects.html (#24246)
    • PASS [expected FAIL] subtest: The entry settings object while executing the compiled callback via Web IDL's invoke must be that of the node document
  • OK [expected TIMEOUT] /html/webappapis/scripting/processing-model-2/integration-with-the-javascript-job-queue/promise-job-entry-different-function-realm.html (#25805)
  • OK [expected TIMEOUT] /html/webappapis/scripting/processing-model-2/integration-with-the-javascript-job-queue/promise-job-entry.html (#25805)
  • PASS [expected CRASH] /streams/readable-streams/crashtests/strategy-worker-terminate.html (#30124)
  • OK /webaudio/the-audio-api/the-audiobuffersourcenode-interface/sub-sample-buffer-stitching.html (#22849)
    • FAIL [expected PASS] subtest: X Stitched sine-wave buffers at sample rate 43800 does not equal [0,0.06264832615852356,0.12505052983760834,0.18696144223213196,0.24813786149024963,0.308339387178421,0.36732959747314453,0.4248766601085663,0.480754554271698,0.5347436666488647,0.5866320133209229,0.6362156271934509,0.6832997798919678,0.7276994585990906,0.7692402601242065,0.8077589869499207...] with an element-wise tolerance of {"absoluteThreshold":0.0038986,"relativeThreshold":0}.
      Index Actual Expected AbsError RelError Test threshold
      [15073] 1.5051586273280000e+12 6.4605611562728882e-1 1.5051586273273540e+12 2.3297645373512466e+12 3.8985999999999999e-3
      [15074] 2.5936898589134216e-1 5.9696805477142334e-1 3.3759906888008118e-1 5.6552283858697683e-1 3.8985999999999999e-3
      Max AbsError of 1.5051586273273540e+12 at index of 15073.
      Max RelError of 2.3297645373512466e+12 at index of 15073.
      assert_true: expected true got false
    • FAIL [expected PASS] subtest: X SNR (-200.11755950096716 dB) is not greater than or equal to 65.737. Got -200.11755950096716. assert_true: expected true got false
  • TIMEOUT [expected OK] /webmessaging/with-ports/017.html (#24486)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, about:blank Test timed out

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 3, 2024

Test results for linux-wpt-layout-2020 from try job (#7393899054):

Flaky unexpected result (12)
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-with-non-reserved-words.html (#16216)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/about-srcdoc-navigation-blocked.window.html
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.html (#29056)
    • PASS [expected FAIL] subtest: Cross-origin navigation started from unload handler must be ignored
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • FAIL [expected PASS] subtest: Same-origin navigation started from unload handler must be ignored assert_equals: expected "?pass" but got "?fail"
  • TIMEOUT [expected OK] /html/browsers/the-window-object/open-close/creating_browsing_context_test_01.html (#29046)
    • TIMEOUT [expected FAIL] subtest: first argument: absolute url Test timed out
  • TIMEOUT [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html (#24057)
    • TIMEOUT [expected FAIL] subtest: Check that popups from a sandboxed iframe escape the sandbox if
      allow-popups-to-escape-sandbox is used Test timed out
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-1.html (#24066)
  • ERROR [expected OK] /html/semantics/scripting-1/the-script-element/defer-script/async-script.html?reload (#29054)
  • TIMEOUT [expected OK] /webmessaging/with-ports/017.html (#24486)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, about:blank Test timed out
  • TIMEOUT [expected OK] /webmessaging/with-ports/018.html (#24485)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, javascript: Test timed out
  • OK /xhr/send-redirect.htm
    • FAIL [expected PASS] subtest: XMLHttpRequest: send() - Redirects (basics) (308 does redirect) assert_equals: expected (string) "GET" but got (object) null
Stable unexpected results that are known to be intermittent (15)
  • TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/shader-uniform-packing-restrictions.html (#28103)
    • NOTRUN [expected PASS] subtest: Overall test
  • TIMEOUT [expected FAIL] /css/compositing/mix-blend-mode/mix-blend-mode-animation.html (#21930)
  • PASS [expected TIMEOUT] /css/css-color/animation/opacity-animation-ending-correctly-002.html (#29216)
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • PASS [expected FAIL] subtest: Matching font-weight: '400' should prefer '350 399' over '351 398'
    • PASS [expected FAIL] subtest: Matching font-weight: '400' should prefer '351 398' over '501 550'
    • PASS [expected FAIL] subtest: Matching font-weight: '430' should prefer '420 440' over '450 460'
    • PASS [expected FAIL] subtest: Matching font-weight: '500' should prefer '351 398' over '501 550'
    • PASS [expected FAIL] subtest: Matching font-weight: '500' should prefer '501 550' over '502 560'
    • PASS [expected FAIL] subtest: Matching font-style: 'normal' should prefer 'oblique 0deg' over 'oblique 10deg 40deg'
    • PASS [expected FAIL] subtest: Matching font-style: 'italic' should prefer 'italic' over 'oblique 20deg'
    • FAIL [expected PASS] subtest: Matching font-style: 'italic' should prefer 'oblique 30deg 60deg' over 'oblique 40deg 50deg' assert_equals: Unexpected font on test element expected 487 but got 532
    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 20deg' should prefer 'oblique 20deg' over 'oblique 30deg 60deg' assert_equals: Unexpected font on test element expected 487 but got 532
    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 20deg' should prefer 'oblique 40deg 50deg' over 'oblique 10deg' assert_equals: Unexpected font on test element expected 487 but got 532
    • And 7 more unexpected results...
  • TIMEOUT [expected PASS] /css/css-transitions/render-blocking/no-transition-from-ua-to-blocking-stylesheet.html (#29187)
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • FAIL [expected TIMEOUT] subtest: Host element with delegatesFocus including no focusable descendants should be skipped promise_test: Unhandled rejection with value: object "TypeError: host.attachShadow is not a function"
    • FAIL [expected NOTRUN] subtest: Area element should support autofocus promise_test: Unhandled rejection with value: object "TypeError: w.document.querySelector(...) is null"
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
  • OK [expected TIMEOUT] /html/semantics/forms/form-submission-0/reparent-form-during-planned-navigation-task.html (#29724)
    • PASS [expected TIMEOUT] subtest: reparent-form-during-planned-navigation-task
  • OK /html/semantics/forms/form-submission-0/text-plain.window.html (#28687)
    • FAIL [expected PASS] subtest: text/plain: Basic File test (formdata event) assert_equals: expected "basic=file-test.txt\r\n" but got ""
    • PASS [expected FAIL] subtest: text/plain: single quote in value (normal form)
  • OK [expected TIMEOUT] /html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html (#23205)
    • PASS [expected NOTRUN] subtest: Check that rel=noopener with target=_self does a normal load
    • FAIL [expected NOTRUN] subtest: Check that rel=noopener with target=_parent does a normal load this.openedWindow.findLink(...) is null
    • FAIL [expected NOTRUN] subtest: Check that rel=noopener with target=_top does a normal load this.openedWindow.findLink(...) is null
  • OK /webaudio/the-audio-api/the-audiobuffersourcenode-interface/sub-sample-buffer-stitching.html (#22849)
    • FAIL [expected PASS] subtest: X Stitched sine-wave buffers at sample rate 43800 does not equal [0,0.06264832615852356,0.12505052983760834,0.18696144223213196,0.24813786149024963,0.308339387178421,0.36732959747314453,0.4248766601085663,0.480754554271698,0.5347436666488647,0.5866320133209229,0.6362156271934509,0.6832997798919678,0.7276994585990906,0.7692402601242065,0.8077589869499207...] with an element-wise tolerance of {"absoluteThreshold":0.0038986,"relativeThreshold":0}.
      Index Actual Expected AbsError RelError Test threshold
      [15073] -1.1510615432495104e+17 6.4605611562728882e-1 1.1510615432495104e+17 1.7816742468754221e+17 3.8985999999999999e-3
      [15074] 2.5936898589134216e-1 5.9696805477142334e-1 3.3759906888008118e-1 5.6552283858697683e-1 3.8985999999999999e-3
      Max AbsError of 1.1510615432495104e+17 at index of 15073.
      Max RelError of 1.7816742468754221e+17 at index of 15073.
      assert_true: expected true got false
    • FAIL [expected PASS] subtest: X SNR (-297.78788494521785 dB) is not greater than or equal to 65.737. Got -297.78788494521785. assert_true: expected true got false
  • TIMEOUT [expected OK] /webaudio/the-audio-api/the-audiocontext-interface/audiocontext-not-fully-active.html (#27664)
  • OK [expected TIMEOUT] /webmessaging/without-ports/017.html (#24486)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, about:blank
  • TIMEOUT [expected OK] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html (#29053)
    • TIMEOUT [expected PASS] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe Test timed out

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 3, 2024

✨ Try run (#7393899054) succeeded.

@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jan 3, 2024

@jdm I gave the temporary drop object a quick try and the "runtime has live children" problem resurfaced, so I propose we keep it as a follow-up in #30971 and merge this as is, how does that sound?

@mrobinson
Copy link
Copy Markdown
Member

I'll send this to the merge queue since I think all issues are resolved now.

@mrobinson mrobinson added this pull request to the merge queue Jan 4, 2024
Merged via the queue into servo:main with commit 90a9300 Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants