Firefox continuously allocates memory, which results ini an OOM crash when headless is enabled
Categories
(Firefox :: General, defect, P3)
Tracking
()
People
(Reporter: lionel, Assigned: stransky)
References
Details
(Keywords: regression)
Attachments
(12 files)
|
1.08 KB,
text/x-python
|
Details | |
|
279.49 KB,
text/x-log
|
Details | |
|
11.52 KB,
text/plain
|
Details | |
|
87.46 KB,
text/x-log
|
Details | |
|
276.12 KB,
application/zip
|
Details | |
|
15.57 KB,
text/x-log
|
Details | |
|
356.09 KB,
application/zip
|
Details | |
|
58.23 KB,
text/x-log
|
Details | |
|
6.90 KB,
text/plain
|
Details | |
|
28.88 KB,
text/x-log
|
Details | |
|
425.93 KB,
text/x-log
|
Details | |
|
388.56 KB,
application/zip
|
Details |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Steps to reproduce:
Run attached python selenium script.
Actual results:
Load fails. Firefox takes up to >11GB, then seemingly dies.
Expected results:
The webpage should load.
| Reporter | ||
Comment 1•7 years ago
|
||
Loading through selenium / geckodriver / marionette the above website fails with Firefox 69.0.1 (Debian package) and 69.0.2 (tar.bz2 download from mozilla.org) on Debian GNU/Linux amd64 architecture. The geckodriver process lives on.
The very same selenium / geckodriver / marionette script in non-headless mode (just comment out the config line for headless) works correctly.
The very same selenium / geckodriver / marionette script in headless mode with Firefox ESR 60.9.0esr (Debian package) (just change the binary_location option to point to it) works correctly.
Loading the very same website in Firefox in normal user mode (not scripted through marionette) works fine (all tested versions).
| Reporter | ||
Comment 2•7 years ago
|
||
Reproduction script.
| Reporter | ||
Comment 3•7 years ago
|
||
The trace-level geckodriver.log file about 2GB, but I attach the beginning and the end.
| Reporter | ||
Updated•7 years ago
|
Comment 4•7 years ago
|
||
There is a content crash logged when checking the trace log. Can you please have a look at https://firefox-source-docs.mozilla.org/testing/geckodriver/CrashReports.html and try to get this minidump files? I would be kinda interested in.
Also have you seen that with the 69.0 or 68.0 release?
| Reporter | ||
Comment 5•7 years ago
|
||
(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #4)
Also have you seen that with the 69.0 or 68.0 release?
I'm not sure I understand the question. My bug report says that the crash is reproduced with Firefox 69.0.1 (Debian package) and 69.0.2 (tar.bz2 download from mozilla.org), but that Firefox ESR 60.9.0esr (Debian package) doesn't crash. This seems to reply to your question that "I have seen that (only) with the 69.0 release" and thus "I have seen that in 68.0 or 69.0". Or do you want me to test specifically 69.0, and not 69.0.1 nor 69.0.2? (Which I would download from http://archive.mozilla.org/pub/firefox/releases/69.0/linux-x86_64/instead of from https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US)
| Reporter | ||
Comment 6•7 years ago
|
||
With the changes suggested at https://firefox-source-docs.mozilla.org/testing/geckodriver/CrashReports.html (namely adding service_args=["--marionette-port", "2828"] and -profile argument), the test behaves differently. The page still fails to load correctly, but I note that instead of taking 100% CPU (one core), firefox now takes about 500% CPU in the firefox-bin process and about 50% CPU in a "Web Content" process.
The minidumps directory is empty. I also attach a new (shorter...) geckodriver.log
| Reporter | ||
Comment 7•7 years ago
|
||
| Reporter | ||
Updated•7 years ago
|
| Reporter | ||
Comment 8•7 years ago
|
||
I tried again the exact same script. This time, I got a 1.3 GB geckdriver.log which I attach in an abridged version. The minidumps directory is still empty.
| Reporter | ||
Updated•7 years ago
|
Updated•7 years ago
|
| Reporter | ||
Comment 9•7 years ago
|
||
Third time is a charm. This time I got a crash. Here is the minidumps directory.
| Reporter | ||
Comment 10•7 years ago
|
||
| Reporter | ||
Comment 11•7 years ago
|
||
And the python process stdout/err:
$ python3 selenium_firefox_minimised_bug.py
*** Using profile: /tmp/tmp579gln_lselenium-tmp-profile
about to get
Traceback (most recent call last):
File "selenium_firefox_minimised_bug.py", line 37, in <module>
driver.get('https://www.public.nm.eurocontrol.int/PUBPORTAL/gateway/spec/index.html')
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: Timeout loading page after 300000ms
| Reporter | ||
Comment 12•7 years ago
|
||
Reproduced with 69.0 (as opposed to 69.0.2) downloaded from http://archive.mozilla.org/pub/firefox/releases/69.0/linux-x86_64/en-GB/firefox-69.0.tar.bz2
With 68.1.0esr downloaded from http://archive.mozilla.org/pub/firefox/releases/68.1.0esr/linux-x86_64/en-GB/firefox-68.1.0esr.tar.bz2:
First run doesn't crash, but was much slower than with 60.9.0esr (Debian package); with the latter a 3s wait is ample enough for the element with ID STATUS_MAP_CONTENTS_ELEMENT_ID to appear. With 68.1.0esr, more that timed out.
Second run with increased timeout to 30s needed about 22s.
Third run timed out after 30s but didn't crash.
Fourth run crashed.
| Reporter | ||
Comment 13•7 years ago
|
||
| Reporter | ||
Comment 14•7 years ago
|
||
| Reporter | ||
Comment 15•7 years ago
|
||
Python output from crashed 68.0.1esr run:
*** Using profile: /tmp/tmp807ssb87selenium-tmp-profile
about to get
about to wait
about to click
Traceback (most recent call last):
File "selenium_firefox_minimised_bug.py", line 44, in <module>
assert(len(driver.window_handles) == 2)
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "selenium_firefox_minimised_bug.py", line 64, in <module>
driver.switch_to.window(wid)
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/switch_to.py", line 112, in window
self._w3c_window(window_name)
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/switch_to.py", line 123, in _w3c_window
send_handle(window_name)
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/switch_to.py", line 119, in send_handle
self._driver.execute(Command.SWITCH_TO_WINDOW, {'handle': h})
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Failed to decode response from marionette
| Reporter | ||
Comment 16•7 years ago
|
||
Confirm that non-headless works like a charm (and fast) with 68.1.0esr
Confirm that headless works reliably (and fast) with 60.9.0esr downloaded from http://archive.mozilla.org/pub/firefox/releases/60.9.0esr/linux-x86_64/en-GB/firefox-60.9.0esr.tar.bz2
| Reporter | ||
Comment 17•7 years ago
|
||
65.0.2 seems to be buggy (didn't wait for it to finish/crash but seemed to have gone into the much-CPU, much-RAM path)
62.0.3 seems to not have this bug (finished within seconds, found the element); run once
63.0.3 seems to not have this bug (finished within seconds, found the element); worked twice then auto-updated itself (pop-up saying so...)
64.0.2 seems to not have this bug (finished within seconds, found the element); worked twice then auto-updated itself (pop-up saying so...)
I deleted the 64.0.2 directory, extracted it again from tarball, made the directory read-only to avoid the auto-update, ran 64.0.2 three more times, worked each time.
Comment 18•7 years ago
|
||
The priority flag is not set for this bug.
:whimboo, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 19•7 years ago
|
||
(In reply to Lionel Elie Mamane from comment #9)
Created attachment 9100092 [details]
3rd run minidumpsThird time is a charm. This time I got a crash. Here is the minidumps directory.
Sorry for the late reply but bug mail got somewhat eaten and I haven't seen your recent comments.
It's great to see that you was finally able to fetch a minidump file. I extracted and uploaded it here: bp-fd82e14e-4092-4079-a6d7-f516f0191024
Can you please check if the newly released Firefox 70 from two days ago, works better now? There was one bug fix which might have helped here.
| Reporter | ||
Comment 20•7 years ago
|
||
(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #19)
Can you please check if the newly released Firefox 70 from two days ago, works better now? There was one bug fix which might have helped here.
It does not work correctly. It went to about 28GB of memory usage, and then aborted/crashed/...
Comment 21•7 years ago
|
||
Does that also happen when you start Firefox manually in headless mode by loading the url like:
/path/to/firefox -headless www.public.nm.eurocontrol.int
While Firefox is running in headless mode, can you please observe the memory usage via the system monitor? Do you see the same behavior?
| Reporter | ||
Comment 22•7 years ago
|
||
(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #21)
Does that also happen when you start Firefox manually in headless mode by loading the url like:
/path/to/firefox -headless www.public.nm.eurocontrol.int
While Firefox is running in headless mode, can you please observe the memory usage via the system monitor? Do you see the same behavior?
Similar behaviour. I ran
/path/to/firefox -headless https://www.public.nm.eurocontrol.int/PUBPORTAL/gateway/spec/index.html
which is the same URL than the first step in the script.
Firefox cycles twice between a few hundred MB and about 18GB memory consumption (resident size), but survives, and then settles to 3.5GB virtual size and 270 MB resident size (but that may be just the OS paging out unused pages).
Note that this is not a fully comparable test because that is only the first step of the script. The script waits for an element to appear, then clicks on it (which opens a popup), switches to the new frame and changes the frame size.
Comment 23•7 years ago
|
||
But I assume it's not crashing under this condition? I would love to have a crash report. If you could check https://firefox-source-docs.mozilla.org/testing/geckodriver/CrashReports.html and try to get such a minidump file that would be great.
Andrew, could you help us so we can figure out what exactly is causing this massive memory allocation in headless mode? I assume there are some tools Lionel could use to provide us with some more information.
Comment 24•7 years ago
|
||
Also we should find a better component for this bug given that this is not geckodriver but Firefox issuing an OOM. For now I will move it into Firefox:General.
Lionel, for the minidump please use the 70 release, or even better would be a nightly build of Firefox:
https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly
| Reporter | ||
Comment 25•7 years ago
|
||
Firefox 70 seems not to crash, only to take an inordinate amount of memory, and then sometimes get killed by OOM condition (my guess) and sometimes just gets stuck doing nothing. It is now in some weird state. Look at top output:
4752 user 20 0 34,166g 0,028t 0 S 0,0 90,9 0:00.00 GLXVsyncThread
4392 user 20 0 34,166g 0,028t 1104 S 0,0 90,9 26:30.71 firefox-bin
Seems not to do anything anymore. These two processes seem to share a memory space. Here's an strace on them:
$ strace -p 4752
strace: Process 4752 attached
futex(0x7ffad5aff3d8, FUTEX_WAIT_PRIVATE, 2, NULL^Cstrace: Process 4752 detached
$ strace -p 4392
strace: Process 4392 attached
restart_syscall(<... resuming interrupted poll ...>^Cstrace: Process 4392 detached
I killed the GLXVsyncThread process, and got only a ".extra" file in the minidumps directory.
| Reporter | ||
Comment 26•7 years ago
|
||
minidumps from frozen firefox 70 after killing it
| Reporter | ||
Comment 27•7 years ago
|
||
| Reporter | ||
Updated•7 years ago
|
| Reporter | ||
Comment 28•7 years ago
|
||
I ran it again, and now it worked. It got to the end of the script. Far more slowly than in non-headless mode or previous versions (like 30 minutes instead of 1 minute) but still it got there. Then it crashed. Somewhere near the end of the script, not sure where, maybe one of the driver.close calls, or one of the driver.switch calls.
| Reporter | ||
Comment 29•7 years ago
|
||
| Reporter | ||
Comment 30•7 years ago
|
||
Comment 31•7 years ago
|
||
Ok, the crash reason seems to be exactly the same as with Firefox 69:
https://crash-stats.mozilla.org/report/index/2d125322-e652-4bcb-af17-cec4a0191025
Would you mind to also test with a Nightly build as I have suggested in my last comment? If that is also still crashing we could try a debug build of Firefox, which might give some more information.
Comment 32•7 years ago
|
||
The usual tool we use to get a basic assessment of memory usage is about:memory. The way it works is you load about:memory, and then click on "measure and save" and it will look at the data structures in memory and save it to a file you specify. I don't know if there's any way to do that from Gecko driver. The chrome JS code for it is in the function saveReportsToFile() in toolkit/components/aboutmemory/content/aboutMemory.js
Comment 33•7 years ago
|
||
A script in Marionette to run for exporting the memory reporter data could look like:
def test_export_memory(self):
import tempfile
path = os.path.join(tempfile.gettempdir(), "memory-report.json.gz")
with self.marionette.using_context("chrome"):
self.marionette.execute_async_script("""
let path = arguments[0];
let resolve = arguments[1];
let memfile = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsIFile);
memfile.initWithPath(path);
let finishDumping = () => {
dump(`\n\nMemory report dumped to: ${memfile.path}\n\n`);
resolve();
};
let dumper = Cc["@mozilla.org/memory-info-dumper;1"]
.getService(Ci.nsIMemoryInfoDumper);
dumper.dumpMemoryReportsToNamedFile(
memfile.path,
finishDumping,
null,
false,
);
""", script_args=[path])
It should be the same with Selenium in running an async script, but as far as I remember only the Python bindings support switching into chrome scope. See Foxpuppet for an example.
Also for loading the web page you should also change the page load strategy to none, so that the get command returns immediately.
Comment 34•7 years ago
|
||
Another user also reported a similar behavior of Firefox on https://github.com/mozilla/geckodriver/issues/1646. I also gave him the instructions in creating a memory dump. Lets see if we can get one.
Comment 35•7 years ago
|
||
bisecting mozilla central builds seems to indicate the following regression range:
this one does NOT HAVE the bug:
https://archive.mozilla.org/pub/firefox/nightly/2018/11/2018-11-14-22-29-27-mozilla-central/firefox-65.0a1.en-US.linux-x86_64.tar.bz2
this one has the bug:
https://archive.mozilla.org/pub/firefox/nightly/2018/11/2018-11-15-10-00-51-mozilla-central/firefox-65.0a1.en-US.linux-x86_64.tar.bz2
Comment 36•7 years ago
|
||
Lionel, can you verify this range? I hope that you both are seeing the same underlying problem.
With those two builds we actually have the following pushlog:
Martin, did you use mozregression? If not would you mind to continue and figure out the exact build which regressed that?
Comment 37•7 years ago
|
||
mozregression ended up with this:
12:42.49 INFO: Last good revision: e762fce85daa2b0399f443c4644c6e61a11b1eb3
12:42.49 INFO: First bad revision: 6fc6bdea42a60b7e3fb426beb073e07a3922913c
12:42.49 INFO: Pushlog:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=e762fce85daa2b0399f443c4644c6e61a11b1eb3&tochange=6fc6bdea42a60b7e3fb426beb073e07a3922913c
I'm running i3 on ubuntu 19.04
Comment 38•7 years ago
|
||
Lionel, what version of Debian are you using? And long much uptime do you have on the machine were you are seeing this bug?
At the login screen in Ubuntu 19.04 I can select "Ubuntu (Wayland)", "Ubuntu" or "i3". I wanted to try with and without Wayland (given the found regression range). To select something other than "i3" I decided to reboot the machine (something I had not done in a few weeks). When I did this I also did "apt-get update / upgrade" to install the latest updates. After the reboot the bug was gone. I really wish I hadn't both installed the updates and rebooted in one go, because now I don't know which of those two things fixed the issue for me. Note, that I have been running my test suite using selenium/geckodriver continuously up until last week or something like that, so I know that the installed Ubuntu packages were "working" to some extent.
If I could speculate a bit; I think there must have been some kind of memory leak or corruption in a system component that eventually reached a threshold which in turn caused system calls made by Firefox to start to fail. And if these calls only rarely fails, maybe Firefox was incorrect error handling for these call causing it to go into 100% CPU with aggressive leaking when these calls suddenly start to fail. Perhaps Firefox, when running with --headless, allocates some kind of "Wayland offscreen surface" and then tries to do some Wayland draw call or something, and if the draw call fails it accidentally leaks the offscreen surface and immediately tries to start over?
Comment 39•7 years ago
|
||
Mike, can you please have a look at this? Looks like it is related to the landing of your patch on bug 1501218 and some combination with recent system libraries. Not sure if something would need to go to the blocklist if possible at all for that kind of problem.
Comment 40•7 years ago
|
||
Btw thank you Martin for nailing it down to that particular range! That is very helpful. Even it's not possible for you to see it anymore.
| Reporter | ||
Comment 41•7 years ago
|
||
The machine is somewhere between Debian 9 and 10; some parts upgraded to 10 and others (in particular, firefox-esr to avoid this bug) not.
I'm not using Wayland.
I don't have information on uptime when running into the bug, but it could have been months or days. The machine has 4 days uptime now, and... doesn't reproduce the bug with Firefox 70, nor with 68.1.0esr. So cannot run the requested tests and checks now, which may be obsolete anyway since martin did the mozregression?
Comment 42•7 years ago
|
||
Bugbug thinks this bug is a regression, but please revert this change in case of error.
Comment 43•7 years ago
|
||
I don't really see why bug 1501218 would have triggered it. In any case, this looks like a memory leak in a system library...
Comment 44•7 years ago
|
||
As Martin mentioned above updating the system seems to have been fixed the problem for him. So this would indicate that there might have been a bug fix release of some system library which was leaking.
I would suggest we wait a couple more days for Lionel's feedback. And if he still cannot see it by early next week we will close this bug as invalid.
| Reporter | ||
Comment 45•7 years ago
|
||
What feedback from me are you waiting that is not contained in comment 41?
Comment 46•7 years ago
|
||
My intention was to wait for:
The machine has 4 days uptime now, and... doesn't reproduce the bug with Firefox 70, nor with 68.1.0esr. So cannot run the requested tests and checks now
I might had the same issue as Martin, or not. But maybe it's better to close this bug for now, and you report back once you ran into the problem again.
Thanks for all your help!
Comment 47•7 years ago
|
||
I was hit with the same bug on a Fedora 30 system, both natively (firefox-69.0.1-3.fc30.x86_64) and in a Debian 10 (buster) docker container (firefox-esr-68.2.0esr-1~deb10u1.).
The fact that the issue manifests also in a container with a different userspace, distro and firefox version, makes it seem like a possible kernel bug.
While prepairing to update my system I first just rebooted, making sure that I'm booting to the same kernel (I had already previously installed a newer one but never booted into it). Turns out that after the reboot I can no longer reproduce, not on Fedora and not in a Debian container.
Possibly uptime (or some kernel state which can happen with time) related?
This comment also confirms that with containers it is dependent on the underlying host: https://github.com/mozilla/geckodriver/issues/1646#issuecomment-553269980
My running kernel both before and after reboot: 5.2.15-200.fc30.x86_64. System uptime pre-restart was in the order of two months.
Comment 48•6 years ago
|
||
I have reproduced this problem and have some further details. Testing was with Firefox 68.3.0esr initially and then 68.5.0esr.
Running a test every day, the problem didn't occur until the system had an uptime of 50 days, and then it occurred consistently. This was running Firefox in a Docker container; the uptime requirement was of the system itself, not the container. The system was running Ubuntu 18.04.2 LTS.
As suspected, the bug is related to these changes: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=e762fce85daa2b0399f443c4644c6e61a11b1eb3&tochange=6fc6bdea42a60b7e3fb426beb073e07a3922913c
With a new Firefox build of 68.5.0esr without Wayland (by hacking toolkit/moz.configure so that wayland_headers() always returns False), the problem doesn't occur.
The figure of 50 days update makes me wonder if the problem actually occurs at 49.7 days, and might be related to the uptime in milliseconds overflowing an unsigned 32 bit int. (E.g. see https://sites.google.com/site/edmarkovich2/whywindows95andwindows98wouldcrashafter49.7daysofuptime)
Updated•6 years ago
|
| Reporter | ||
Comment 49•6 years ago
|
||
I run into the bug again, after inadvertently upgrading firefox-esr. Uptime 108 days.
| Assignee | ||
Comment 50•6 years ago
|
||
Can you try to get valgrind report of the used memory?
(https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Valgrind)
If that's wayland related and it's reproducible only when Wayland builds are enabled and under headless it looks like
Firefox takes Wayland path somewhere as:
gdk_display_get_default() returns null on headless
"GDK_IS_X11_DISPLAY(gdk_display_get_default()" which is out standard "is wayland enabled" check is also true on headless
do we may run Wayland path on headless although it's not intended.
| Assignee | ||
Comment 51•6 years ago
|
||
Let's do better headless check on Bug 1619270 first.
Comment 52•6 years ago
|
||
I can confirm that the problem is fixed for me in Firefox 75.0b1 (which contains the fix for bug 1619270).
Comment 53•6 years ago
|
||
Esa and Lionel, could you both also check with a recent Nightly build if it works for you now? Thanks a lot!
Comment 54•6 years ago
|
||
Given the confirmation from Tim from nearly a month ago that it works for him now, and no reply from Esa and Lionel, I'm going to mark this bug as fixed now.
Comment 55•6 years ago
|
||
I actully dug up this ticket some minutes before your last comment (funny coincidence). I'd have tested this sooner but machines with a real 50 day uptime aren't easy to come up with overnight :) There are probably several ways to fake that, not sure if even turning the date would have worked but that's irrelevant now.
Tested with Mozilla Firefox 75.0b11 and can no longer reproduce
Updated•6 years ago
|
| Reporter | ||
Comment 56•6 years ago
|
||
At uptime 64 days, downloaded today firefox nightly 79.0a1. Didn't reproduce the bug with it.
Comment 57•6 years ago
|
||
That's great to hear. Thanks a lot for your feedback!
Description
•