Closed Bug 1347739 Opened 3 years ago Closed 3 years ago
Message Event `source` accessor crashes tab
Accessing the `source` attribute of a user-created `ExtendableMessageEvent` object causes the browser tab of the current client to crash. Steps to reproduce: 1. Execute the following code in the global scope of a service worker: new ExtendableMessageEvent('type').source; Expected result: the expression should evaluate to `null`  Actual result: the browser tab crashes This appears to originate from the accessor function itself (rather than the property access). The following code does *not* cause a crash: var e = new ExtendableMessageEvent('type'); var desc = Object.getOwnPropertyDescriptor(ExtendableMessageEvent.prototype, 'source'); var getter = desc.get; However, invoking the accessor directly also causes a crash: getter.call(e); No crash occurs for `ExtendableMessageEvent` objects that have been constructed internally, i.e. for `message` event handlers. The only open bug report I can find for the `source` attribute is bug 1196097, but that does not seem related to this issue. Operating System: Ubuntu 16.04 (x86_64) Browser: Firefox Nightly Contents of `platform.ini` file: BuildID=20170314110401 Milestone=55.0a1 SourceRepository=https://hg.mozilla.org/mozilla-central SourceStamp=6d38ad302429c98115c354d643e81987ecec5d3c  https://w3c.github.io/ServiceWorker/#extendablemessage-event-source > 4.8.4. `event.source` > > The `source` attribute must return the value it was initialized to. When the > object is created, this attribute must be initialized to null. It represents > the Client object from which the message is sent.
We're hitting this MOZ_CRASH: https://hg.mozilla.org/mozilla-central/annotate/8dd496fd015a/dom/workers/ServiceWorkerEvents.cpp#l1194 I guess we should just return nullptr instead.
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Mike, do you have a test for this already written?
This fixes the crash locally for me. I'll wait for Mike to respond before writing a test. If he has one I can either import it or just wait for it to merge from upstream.
Attachment #8848073 - Flags: review?(bugmail)
I also checked MessageEvent. It does not have this problem: https://dxr.mozilla.org/mozilla-central/source/dom/events/MessageEvent.cpp#90
Attachment #8848073 - Flags: review?(bugmail) → review+
(In reply to Ben Kelly [not reviewing due to deadline][:bkelly] from comment #2) > Mike, do you have a test for this already written? Sure do--it's on its way to Web Platform Tests via the Chromium project's automated "upstreaming" process. Currently under review at https://codereview.chromium.org/2751113005/
Ok. I'm just going to land this then. We'll get the test when it merges around. Thanks!
Pushed by email@example.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/77b0e80d2bd3 Don't crash if an ExtendableMessageEvent object has a null source. r=asuth
We might as well uplift this to beta/aurora since its such an easy fix.
Comment on attachment 8848073 [details] [diff] [review] Don't crash if an ExtendableMessageEvent object has a null source. r=asuth Fix a potential crash. Aurora54+ & Beta53+.
Setting qe-verify- based on comment 10.
You need to log in before you can comment on or make changes to this bug.