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

Missing ReferenceError on undeclared variable references? #51

Closed
esbena opened this issue Jun 16, 2015 · 2 comments
Closed

Missing ReferenceError on undeclared variable references? #51

esbena opened this issue Jun 16, 2015 · 2 comments

Comments

@esbena
Copy link
Contributor

esbena commented Jun 16, 2015

Jalangi squelches the ReferenceError that would occur on a references to an undeclared variable through its use of J$.I.

This breaks feature-detection with try-catch blocks as seen below:

try {
    document; // <-- supposed to throw in non-browser environments
} catch (e) {
    standalone = true;
} 

Suggestion: the jalangi-instrumentation-pattern with J$.I(...) for undeclared variables should be disabled by default.
Thoughts?


Small example that showcases the discrepancy between a jalangi-runtime and a node-runtime:

test.js:

DOES_NOT_EXIST;

test_jalangi_.js

...
J$.X1(17, J$.I(typeof DOES_NOT_EXIST === 'undefined' ? DOES_NOT_EXIST = J$.R(9, 'DOES_NOT_EXIST', undefined, true, true) : DOES_NOT_EXIST = J$.R(9, 'DOES_NOT_EXIST', DOES_NOT_EXIST, true, true)));
...
$ node src/js/commands/jalangi.js test.js
$ node test.js
...
(function (exports, require, module, __filename, __dirname) { DOES_NOT_EXIST;
                                                              ^
ReferenceError: DOES_NOT_EXIST is not defined
...
@msridhar
Copy link
Contributor

The discussion on SRA-SiliconValley/jalangi#19 is probably relevant. I'd like to see a fix to this issue as well. We should be able to do something simpler now that we don't need to support record-replay. I am personally still ok with just getting rid of the J$.I callback in general and just doing:

DOES_NOT_EXIST = J$.R(9, 'DOES_NOT_EXIST', DOES_NOT_EXIST, true, true)));

The negative effect is we lose the readPre() callback for undeclared variables, but to me that is not compelling given that we are currently breaking semantics.

ksen007 added a commit that referenced this issue Jun 22, 2015
@ksen007
Copy link
Contributor

ksen007 commented Jun 22, 2015

The fix was a bit involved because typeof DOES_NOT_EXIST won't throw an exception.

@ksen007 ksen007 closed this as completed Jun 22, 2015
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

3 participants