weird floating point results, fixed by adding debugger statement
Reported by
marc...@gmail.com,
Apr 18 2016
|
|||||||
Issue descriptionChrome Version : Version 50.0.2661.75 m URLs (if applicable) : Other browsers tested: none Please provide any additional information below. Attach a screenshot if possible. I'm working on a game. in one level "pumpkin"-bombs drop from the sky. some stopped going off after the recent update to chrome. I load a script as text from the server, this gets turned into working code using eval(). All fine. While executing this script on the new chrome version, I noticed weird behaviour of my script. I added a debugger; statement to the script and the issue went away. Removing the debugger; statement made the problem appear again. I debugged what was happening and noticed I was getting strange floating-point values for my "active" property. the active property represents the time since the pumpkin has been activated by player proximity. I was seeing things like "-2.6380304608078758e+131" where I was expecting a float representing time in seconds (incremented every frame by the time-step). I also noticed pumpkins detonating that are outside of the proximity. I have two links, one with the working version using debugger;. The debugger statement actually never gets hit, but likely prevents optimization. http://data.cyberlympics.com/html/game.html?param=AntiMiner_1_LEVEL_11&view=1&shader=3 the other with no debugger; statement that causes issues. how to detect: - player is invincible, you can just stay put and wait - wait for "init pumpkin" in the console - conditional breakpoint checking c.active for weird float, not sure how to do that myself... - the issue becomes visible, when some of the 'pumpkins' don't detonate (they change color and remain that way) http://data.cyberlympics.com/html/game.html?param=AntiMinerBad_1_LEVEL_11&view=1&shader=3 //script function(PARAM){ var _ = PARAM._; var c = _.custom; if(!c){ _.custom = c = {active:0}; _.scale = 0.5; console.log('init pumpkin 1'); } if(_.z){ if(_.z<=200) _.alpha = 1; else _.alpha = 1-Math.min(1,(_.z-200)/400); } if(_.vz) return; if(!c.active){ var foe = _g_.getClosestFoe(_.x,_.y,400,_.gid); if(foe){ c.active = PARAM.time+0.0001; } }else{ c.active+=PARAM.time; if(c.active<0){ //never enters here, even with c.active == -2.6380304608078758e+131 //but I am not sure what that number really is console.log('pumpkin error'); debugger;//comment out this code, and the weird floats occur } if(c.active>4){ _.scale = 1; _.hue = 16; _.omode = 0.42; PARAM.me.kill(); }else{ var s = Math.qsin(Math.sqr(c.active)*5)+1; _.hue = (84+~~(s*16))%100; _.omode = 0.411+0.01*s; _.scale = 0.4+s*0.1; } } }
,
Apr 26 2016
,
Apr 26 2016
This smells like a crankshaft bug. I'll investigate tomorrow. Can you check in the meantime whether the bug goes away if you insert "try {} catch (e) {}" instead of the debugger statement?
,
Apr 26 2016
,
Apr 27 2016
I just tried it and yes it goes away!
,
Apr 27 2016
,
Apr 27 2016
I haven't been able to reproduce the issue with your instructions. I keep seeing "init pumpkin 1" on the console, but "pumpkin error" never occurs. In fact, I found that the player is not invincible at all, and once level 2 starts, the spiders kill the player pretty quickly, causing the game to come to a halt.
,
Apr 27 2016
sorry about that. I noticed myself, when I posted my last message. I have continued to work on the game, which in turn broke the bug-demo. the player is now invincible again and the level should not switch for 10000 seconds http://data.cyberlympics.com/html/game.html?param=AntiMinerBad_1_LEVEL_11&view=1&shader=3 by the way, i'm using Windows 7 64bit
,
Apr 28 2016
,
Apr 28 2016
I've come accross the same bug with different scripts all following the same pattern. the script is converted to code using eval() and reused for multiple units. I've also had cases, where I believe the integer values were corrupt (I did not prepare another example). Issue was again fixable using debugger statement.
,
Apr 28 2016
Do you have a more compact repro that does not have a lot of dependencies? Something like a single HTML page? That would speed up things for me, by a lot.
,
Apr 28 2016
I'm afraid not. I haven't really been trying to reproduce the bug, I was more interested in curing it in the fastest possible way. I don't know if the bug would be reproducable with other situations either. I've just tried something I thought might work, but this did not reproduce the error:
<html>
<head>
<script>
var func = eval("(function(data, t){ if(!data.time){ data.time=t;} else {data.time+=t; if(data.time<0){ console.error(data.time); } } })");
var objs = [];
for(var i=0;i<100;i++){
objs.push({data:{}});
}
var last = Date.now();
function update(){
var now = Date.now();
var t = (now-last)/1000.0;
last = now;
for(var i=0;i<objs.length;i++){
func(objs[i].data, t);
}
}
setInterval(update,10);
</script>
</head>
<body>
</body>
</html>
,
May 3 2016
I've noticed the problem can pop up, even with the debugger statement. It's just a lot less likely. It popped up when I was adding a completely unrelated webaudio sound. This could point to some deeper issue. possibly not even related to the code/situation I found it in.
,
May 31 2016
I've come accross another hint: I believe the constant values are affected (could be coincidence of course). The issue happened in different code, the script was also created using eval.
the relevant code:
var td = obj._;
td.custom = {hue:data.hue,hide:-1,id:td.id};
console.log('create turret '+td.id);
console.log(td.custom);
output that occurred:
Object {hue: 0, hide: 4.522802609592432e-193, id: 1447}
the value for hide can also be small/large and positive the range does not seem restricted. hide is set to the constant value -1, but directly after wards it already has an incorrect value.
http://data.cyberlympics.com/screen/160531bug.jpg
http://data.cyberlympics.com/html/game.html?param=AntiMinerT_1
WASD to move, mouse to target. pick up a red extra from the bottom row of objects above you. right click, this should place a turret. you will likely have to pick up a few extras and place a few turrets for the bug to occur.
,
May 31 2017
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
May 31 2017
I have not come across the issue mentioned here anymore and removed the debugger statement from the code. It's likely the bug got fixed with another issue.
,
Jun 1 2017
Assuming it's fixed then. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by kavvaru@chromium.org
, Apr 19 2016Labels: Te-NeedsFurtherTriage