Closed Bug 1609668 Opened 6 years ago Closed 5 years ago

Crash during download via ServiceWorker

Categories

(Core :: IPC, defect)

79 Branch
Unspecified
Windows
defect
Not set
normal

Tracking

()

RESOLVED FIXED
83 Branch
Tracking Status
firefox83 --- verified

People

(Reporter: vobruba.martin, Assigned: jld)

Details

Crash Data

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36

Steps to reproduce:

Go to https://stat-info.cz/firefox-sw-readablestream.html and click Download button.

Actual results:

In background the page navigates to URL handled by ServiceWorker. SW responds with ReadableStream which is fetching data chunk by chunk (16MB) and download of 50GB file is initiated.

After downloading of 12-16GB tab crashes on my Mac. I have no problem to complete the download on Linux/Windows.

Unfortunately no crash report is generated but here are crash reports from another site which uses this technique for downloading:
https://crash-stats.mozilla.org/report/index/f023d407-4b56-4f59-8b12-5401b0200115
https://crash-stats.mozilla.org/report/index/abad85cc-6872-4bb5-87ad-ca10d0200115

Expected results:

The download should be completed without any crash.

Alternative steps to reproduce this issue:

  1. Open https://mab.to/oOr1opalDOu0N
  2. Right click on folder "01_music ~ 2020-01-17" and click "Download as a ZIP archive"
  3. Select location where to save the ~ 1.38GB file
  4. If download is successful (no crash) click "Close" button in the left bottom corner and repeat from 2)

For me the tab crashed 4 times of 10 download attempts. Here are the crash reports:
https://crash-stats.mozilla.org/report/index/ca0f9218-f071-446c-9845-cd5500200117
https://crash-stats.mozilla.org/report/index/42086aa3-754c-400d-bb32-4d7d50200117
https://crash-stats.mozilla.org/report/index/5bc2db56-1f36-42e8-9b6c-76c380200117
https://crash-stats.mozilla.org/report/index/41ad6545-993f-4ff4-b48f-784940200117

Hi,

I tried reproducing the crash on my end but I'm able to download both files provided. I tried on Firefox Nightly 74.0a1 (2020-01-28) (64-bit) on macOS 10.14.

Indeed it's downloading chunk by chunk (16MB) for a download of 50GB file. It took several hours but it finally finished downloading successfully. FF didn't crash but I'm unable to open file or extract what's inside.

When trying the alternative steps within https://mab.to/oOr1opalDOu0N link provided, I managed to download the file without inconveniences as well.

I'm going to set a component so that the devs can take a look at the crash reports provided.

Does this issue occur with a fresh profile? You can find the steps here: https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles?redirectlocale=en-US&redirectslug=Managing-profiles#w_starting-the-profile-manager

Can you please download Firefox Nightly from here: https://nightly.mozilla.org/ and retest the problem and see if the issue still occurs there as well?

Best,
Clara

Component: Untriaged → Crash Reporting
Flags: needinfo?(vobruba.martin)
Product: Firefox → Toolkit

I use a fresh profile on the current stable Firefox 72.0.2 to reproduce this issue.

As you recommended I tried the Nightly 74.0a1 several times (hundreds of GB downloaded) and it didn't crash for me either.

Flags: needinfo?(vobruba.martin)

The priority flag is not set for this bug.
:gsvelto, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(gsvelto)

Martin, can you confirm that this issue is not happening for you anymore as per comment 3? I've looked at the crashes in comment 0 and in comment 1 but they point to at least two different causes, one of which (illegal instruction executed) is really odd.

Flags: needinfo?(gsvelto) → needinfo?(vobruba.martin)

I tried the current stable Firefox 73.0 and it crashed. See report here https://crash-stats.mozilla.org/report/index/51cc0b4b-8340-410f-85df-ed5710200213 . I will try beta and nightly versions later.

Thanks Martin, the cause for that crash report is even different compared to the previous ones. I suspect there might be a problem with your machine and since it only shows up when downloading very large files it might be faulty memory. Could you run a diagnostic on your Mac's memory? You can use memtest86 (which requires booting from an external USB stick) or macOS memory diagnostic tool (see here on how to launch it, under "Check Your Memory Using Apple Diagnostics" paragraph). memtest86 is preferable as it gives very detailed results but I never ran it on a Mac before so I don't know if it works there.

P4 since we couldn't confirm this yet.

Priority: -- → P4
Flags: needinfo?(vobruba.martin)

Thanks, this is definitely actionable. I'll confirm the bug and attach the crash signature.

We're statically allocating a 32 KiB buffer on the stack and this seems to be causing stack overflows at least on Windows, but I suppose the issue affects all platforms.

Status: UNCONFIRMED → NEW
Crash Signature: [@ _chkstk | mozilla::ipc::IPCStreamSource::DoRead]
Component: Crash Reporting → IPC
Ever confirmed: true
OS: Unspecified → Windows
Priority: P4 → --
Product: Toolkit → Core
Summary: Crash during download via ServiceWorker on MacOS → Crash during download via ServiceWorker
Version: 72 Branch → 79 Branch

bp-8d59ed91-d168-4db1-8f09-871b40201002 shows that there's some recursion making the problem worse: 7 activations of DoRead on the stack, including the one that overflowed. I looked at a disassembly and there don't seem to be any other functions involved in that recursion that have large frame sizes, so it should be enough to move that one allocation to the heap.

Assignee: nobody → jld
Pushed by jedavis@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/19e5e9a8e377 Move 32k buffer in IPCStreamSource::DoRead to the heap to avoid stack overflow. r=asuth

I will test the change using nightly build. Is there any chance that this change will be backported to the current stable/beta version?

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 83 Branch

Martin, could you please verify that the bug is fixed on Firefox 83 Beta 2 (https://archive.mozilla.org/pub/firefox/candidates/83.0b2-candidates/build1/)?

Flags: needinfo?(vobruba.martin)

I have done many tests using nightly or the latest beta and I can confirm that the bug is fixed. Is there any chance that this change will be backported to the current stable version?

Flags: needinfo?(vobruba.martin)

Thank you, Martin!
I will set the "firefox83" flag to verified.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: