New issue
Advanced search Search tips

Issue 812069 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 396021
Owner:
Closed: Mar 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature


Show other hotlists

Hotlists containing this issue:
Devader-Requires


Sign in to add a comment

Mode that always throws on NaN/Infinity

Project Member Reported by fs...@chromium.org, Feb 14 2018

Issue description

This is a hail Mary sort of Bug.

Would it be possible to create a new JS mode (akin to "use strict";) that would automatically throw when a JS variable becomes NaN or Infinity? Would it be possible to do this on DevTools instead?

I feel like in most JS development a NaN/Infinity is always an error and is usually caught way too late. It would be amazing if the error was caught the moment the variable is assigned to one of those values.


 

Comment 1 by adamk@chromium.org, Feb 14 2018

Components: -Blink>JavaScript>Language
Getting such a mode to work fully seems like it'd be quite a deep set of changes to V8, since you'd want it to happen in all paths and all tiers of optimization. I don't think this is something we'd want to do.

I doubt that the devtools part is much more tractable, but I'm happy to leave that label for them to answer.

Comment 2 by capn@chromium.org, Feb 20 2018

Note that x86* can trap floating-point exceptions that by default are masked. This includes invalid operations (NaN), division by zero (infinity), overflow (infinity), underflow (denormal), and inexact results (precision loss).

On Linux you can control these using sigfpe(), on Windows you can use _controlfp() and signal().

Note that these are exceptions at the native code level (actually at the machine level), so correlating them to JavaScript code is the harder part. That said I assume V8 has ways of handling some of these low-level exceptions, so it might not be all that hard to get it working as desired.

[*] I think other CPU architectures support this too, because these exceptions are defined by the IEEE-754 floating-point standard.

Comment 3 by alph@chromium.org, Mar 3 2018

Owner: kozy@chromium.org
Status: Assigned (was: Untriaged)
Alexey, can we make embedder to play with sigfpe when debugger is active?

Comment 4 by kozy@chromium.org, Mar 6 2018

Mergedinto: 396021
Status: Duplicate (was: Assigned)

Sign in to add a comment