Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when code relies on output of toString() on a Function #162

Open
MadhuNimmo opened this issue Mar 9, 2021 · 1 comment
Open

Bug when code relies on output of toString() on a Function #162

MadhuNimmo opened this issue Mar 9, 2021 · 1 comment

Comments

@MadhuNimmo
Copy link
Contributor

Hi,
I found out that the below example breaks jalangi in a way that the use of variable z within the new Function constructor ends up getting instrumented multiple times , once as the variable itself and again as part of the string passed to new Function

(function () {
  var z = function () {
    return "z";
  };
  function bar() {
    return new Function("return(" + z + ")");
  }
  var next = bar();
  var final = next();
  final();
})();

If I try to print the functions that get invoked in the process, I get the below ones:

297 [Function] ''
153 [Function: bar] 'bar'
105 [Function: Function] 'Function'
185 [Function] ''
217 [Function] ''
61 [Function: Fe] 'Fe'
109 [Function: N] 'N'
181 [Function: T] 'T'
189 [Function: Rt] 'Rt'
197 [Function: X1] 'X1'
269 [Function: Fr] 'Fr'
277 [Function: Ra] 'Ra' 
@msridhar
Copy link
Contributor

msridhar commented Mar 9, 2021

Thanks @MadhuNimmo. The original code relies on the fact that calling toString() on a Function prints its code. After instrumentation, the output of toString() changes (to be the instrumented code), which breaks this test. We should probably update the documentation to indicate this is a case where Jalangi can alter behavior.

@msridhar msridhar changed the title Expected bug Bug when code relies on output of toString() on a Function Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants