question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

An issue about the Math.max().

See original GitHub issue

When I passed NaN and an object with the “valueOf” attribute value as a callable function to the first and second parameters of Math.max, chakra did not execute this function. According to the ES10 standard, the ToNumber operation is performed on each parameter of Math.max, and the “valueOf” attribute value function of the second parameter will be executed.

version

chakra-1_11_22

command

ChakraCore/out/Debug/ch testcase.js

testcase

var NISLFuzzingFunc = function(){
    var a = {
        valueOf: function(){
            print(1);
        }
    };
    var b = Math.max(NaN,a);
};
NISLFuzzingFunc();

Output

No output.

Expected behavior

Output 1.

Contributor : @Haobin-Lee

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Harsh-Shedgecommented, Jul 10, 2022

Is this issue resolved? Can I try to work on this?

1reaction
YaseenYocommented, Sep 8, 2021

@rhuanjl Can We do this?

    let max = value1;
    let nextVal;
    let isNaN = false;

    for (let i = 1; i < arguments.length; i++) {
        nextVal = +arguments[i];
        if (nextVal !== nextVal) {
            isNaN = true;
        }
        else if(isNaN){
             continue;
        }
        else if ((max < nextVal) || (max === nextVal && max === 0 && 1/max < 1/nextVal)) { 
            max = nextVal;
        } 
    }

    if(isNaN){
         return NaN;
    }
    else {
         return max;
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Math.max() - JavaScript - MDN Web Docs
The Math.max() function returns the largest of the numbers given as input parameters, or -Infinity if there are no parameters.
Read more >
An issue about the Math.max(). · Issue #781 · mozilla/rhino · GitHub
Description. When I passed NaN and an object with the "valueOf" attribute value as a callable function to the first and second parameters...
Read more >
JavaScript Math max() Method - GeeksforGeeks
The JavaScript Math max() Method is used to return the largest of zero or more numbers. The result is “-Infinity” if no arguments...
Read more >
Why Math.max() is Less Than Math.min() in JavaScript
So, Math.max() starts with a search value of -Infinity , because any other number is going to be greater than -Infinity. Similarly, ...
Read more >
JavaScript Math max() Method - W3Schools
Definition and Usage. The Math. max() method returns the number with the highest value.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found