Closed Bug 573646 Opened 15 years ago Closed 15 years ago

JavaScript Tests - catch memory allocation error

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: eric.hennigan, Unassigned)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (compatible; Konqueror/4.4; Linux) KHTML/4.4.2 (like Gecko) Kubuntu Build Identifier: Running python jstests.py with options: -x spidermonkey-n.tests -x slow-n.tests --timeout=60 --failure-file failures.txt -O output.txt produces a python stack crash on some tests. Of course, the crash is a result of buggy code that I introduced into tracemonkey. But I'd expect the jstests.py driver to catch such errors cleanly. Running python jstests.py with options: -x spidermonkey-n.tests -x slow-n.tests --timeout=60 --failure-file failures.txt -O output.txt produces a python stack crash on some tests. Of course, the crash is a result of buggy code that I introduced into tracemonkey. But I'd expect the jstests.py driver to catch such errors cleanly. [ 352| 5| 9] 12% =====> | 439.7sException in thread Thread-366: Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner self.run() File "/usr/lib/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) File "/home/erich/projects/jsflow/js3/js/src/tests/tests.py", line 19, in th_run_cmd p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=close_fds) File "/usr/lib/python2.6/subprocess.py", line 633, in __init__ errread, errwrite) File "/usr/lib/python2.6/subprocess.py", line 1049, in _execute_child self.pid = os.fork() OSError: [Errno 12] Cannot allocate memory Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner self.run() File "/usr/lib/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) File "/home/erich/projects/jsflow/js3/js/src/tests/workers.py", line 86, in run result = task() File "jstests.py", line 52, in __call__ return self.test.run(self.js_cmd_prefix, OPTIONS.timeout) File "/home/erich/projects/jsflow/js3/js/src/tests/tests.py", line 69, in run out, err, rc, dt = run_cmd(cmd, timeout) TypeError: 'NoneType' object is not iterable Reproducible: Always Steps to Reproduce: 1. write a test case, or edit interpreter to allocate large amounts of memory 2. run jstests.py Actual Results: jstests.py produces python stack trace as result of uncaught exception Expected Results: report that one or more tests in the regression suite failed as a result of allocation issues. I think for memory allocation errors, it would be nice to limit the amount of memory that the JS VM has while it is running a test case. This way the JS VM will run out of memory, rather than the host system. This can be accomplished (for example) by first measuring how much memory each test requires as it is run and then taking the max (and possibly adding a bit extra, just in case).
I've got a solution (not too elegant) that works pretty well for me (Linux 2.6.32-22-generic). It simply limits the memory size for each test job to 1GiB.
(In reply to comment #1) > Created an attachment (id=453172) [details] > Limits the memory usage by each job to 1 GiB > > > I've got a solution (not too elegant) that works pretty well for me (Linux > 2.6.32-22-generic). It simply limits the memory size for each test job to 1GiB. The 'resource' module doesn't exist on Windows. Can you change the patch not to use it on Windows, sort of like how we do for close_fds?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Ah, good catch. I tried (briefly) to see whether python supports resource limits in Windows, and failed to find anything. So this new patch will set memory limit only on machines that support the resource module.
Attachment #453172 - Attachment is obsolete: true
Ok, this works fine for me on Windows. Would you like to request a review? Also let me know if you have access to land this to tracemonkey or if I will need to do it.
Thanks for testing it on Windows. A review would be nice, and I haven't been granted access to land this in tracemonkey.
(In reply to comment #5) > Thanks for testing it on Windows. > > A review would be nice, and I haven't been granted access to land this in > tracemonkey. Please request a review by clicking "details" for your patch, and then setting Review to "?" with a requestee name. You can put me.
Attachment #453308 - Flags: review?(dmandelin)
Attachment #453308 - Flags: review?(dmandelin) → review+
http://hg.mozilla.org/tracemonkey/rev/2c5caef08ec3 Argh. I forgot to add the "r=dmandelin" to the commit message. But it should be easy enough to find here.
Whiteboard: fixed-in-tracemonkey
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: