Eval in while loop causes crash
Reported by
hakerh403@gmail.com,
Jul 12 2017
|
|||||||||
Issue description
UserAgent: Nothing to see here.
Steps to reproduce the problem:
Run this code:
(a => {while(((a = (a | 0) + 1 | 0) | 0) !== 0)eval('')})(0)
What is the expected behavior?
Like in all other browsers, the script should complete after few seconds and return undefined.
What went wrong?
However, the script causes crash in chrome. The message says "chrome ran out of memory while displaying this webpage". I really don't see why does it causes a crash. Somewhere chrome is allocating memory, but not deallocating. In gecko engine the script completes without crash in just few seconds (9.82 on average).
Did this work before? No
Chrome version: 59.0.3071.115 (Official Build) (64-bit) (cohort: Stable) Channel: stable
OS Version:
Flash Version: The flash is disabled
,
Jul 15 2017
I'm able to reproduce this issue on Latest Chrome Beta#60.0.3122.66 for 'Win7'.
,
Jul 17 2017
Able to reproduce this issue(as in crash@console.jpg) on Win-10 using chrome reported version #59.0.3071.115 and latest canary #61.0.3159.0.
Issue is not seen in OS-Mac and OS-Linux.
This is a non-regression issue as it is observed from M50 old builds. In M45 build, the code: (a => {while(((a = (a | 0) + 1 | 0) | 0) !== 0)eval('')})(0) neither returned undefined nor did it crash, rather it showed errors as in the attached screen shot(crash_M45@console.jpg).
Hence, marking it as untriaged to get more inputs from dev team.
Thanks...!!
,
Jul 18 2017
memory sheriffs, PTAL
,
Jul 18 2017
This is basically a
while(true) eval('');
with 'a' being context allocated. At the first sight I don't see why we wouldn't run OOM here.
Adam, any opinion on this one?
,
Jul 18 2017
,
Jul 18 2017
I'm skeptical that there's anything actionable here, especially considering that it's an infinite loop (the only way I can imagine this "completing" in firefox is if the user allows the browser to kill the script).
,
Jul 18 2017
@adamk. My original script is not infinite loop. According to the ES scep, integer overflow is not undefined behavior, so it will iterate exactly 2**32 iterations.
,
Jul 18 2017
Ah, sorry, I didn't look closely enough at the original test case. Re: #5, I actually don't know why this should run OOM. Yes, 'a' is context-allocated, but that's only one variable. The eval inside the loop will create a new JSFunction each time through, but I don't see what should be keeping them alive, so this does smell like there could be a GC issue to me.
,
Jul 18 2017
I just checked locally on my machine. In d8 the script runs actually through in ~12min on my z840 without causing OOM. I assume that the script is killed before completing when executed in Chrome. I profiled a much shorter run going until 2**28. The GC profile looks fine in the sense that we do not leak. Ideally there wouldn't be any allocations but the garbage that is created is cleaned up afaics. $ time out/x64.release/d8 --trace-opt --prof script.js [marking 0x3e9f9a0c011 <JSFunction a (sfi = 0x3d2c8272cc29)> for optimized recompilation, reason: hot and stable, ICs with typeinfo: 7/7 (100%), generic ICs: 1/7 (14%)] [compiling method 0x3e9f9a0c011 <JSFunction a (sfi = 0x3d2c8272cc29)> using TurboFan OSR] [optimizing 0x3e9f9a0c011 <JSFunction a (sfi = 0x3d2c8272cc29)> - took 1.493, 0.647, 0.013 ms] [marking 0x8bd9a3856e1 <JSFunction (sfi = 0x3d2c8272d3e1)> for optimized recompilation, reason: small function, ICs with typeinfo: 0/0 (100%), generic ICs: 0/0 (0%)] [compiling method 0x8bd9a385729 <JSFunction (sfi = 0x3d2c8272d3e1)> using TurboFan] [optimizing 0x8bd9a385729 <JSFunction (sfi = 0x3d2c8272d3e1)> - took 0.053, 0.162, 0.004 ms] [completed optimizing 0x8bd9a385729 <JSFunction (sfi = 0x3d2c8272d3e1)>] real 0m45.381s user 0m51.672s sys 0m1.800s As #9 pointed out we do actually allocate JSFunctions which also causes GCs. However, if I interpret the performance profile correctly (profview), we spend quite some time in the runtime. Top buckets are: - 11% v8::internal::Runtime_ResolvePossiblyDirectEval - 9% v8::internal::CompilationCacheTable::LookupEval - 8% v8::internal::Factory::NewFunctionFromSharedFunctionInfo I don't think that this is a GC issue.
,
Jul 18 2017
Aaaand... the logfiles.
,
Jul 19 2017
+bmeurer
,
Jul 19 2017
,
Jul 19 2017
,
Jun 5 2018
Not sure, but it seems that this may be related to https://github.com/nodejs/node/issues/21142 and probably https://github.com/nodejs/node/issues/19733 since the issue appears only when devtools are open. IIUC, the inspector retains a reference to eval'd code in case the user wants to inspect it (see the 4th comment on the second linked issue). |
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by junov@chromium.org
, Jul 12 2017