-
Notifications
You must be signed in to change notification settings - Fork 28
preservation of ReferenceErrors when reading undefined global variables #19
Comments
I do not have a suitable solution for this problem. Any ideas? On Dec 11, 2013, at 12:09 PM, Manu Sridharan [email protected] wrote:
|
Simon and I discussed this. So right now, a read of a variable J$.I(typeof x === 'undefined' ? x = J$.R(9, 'x', undefined, true) : x = J$.R(9, 'x', x, true)) This code checks if Could we instead instrument as follows: J$.I(typeof x === 'undefined' ? (J$.RU(9, 'x', undefined, true), x) : x = J$.R(9, 'x', x, true))
Thoughts? |
Correction to the above; it seems that // s is the variable name
function checkDeclared(s) {
var glob = (function () { return this; })();
// this doesn't handle monkey-patching
return glob.hasOwnProperty(s);
} So, the scheme from the previous comment could be preserved, replacing This is getting rather complex. The whole purpose of this scheme is to preserve the |
A variable may be initialized in record phase, but may not be initialized in the replay phase (e.g. window object). Does this take care of this? Koushik On Dec 11, 2013, at 1:21 PM, Manu Sridharan [email protected] wrote:
|
Ah, good point. We could take care of this by (1) throwing the |
Hi, An alternative solution, not sure if it will solve the problem completely: One way to distinguish undeclared variable from undefined variable is using try{x;}catch(e){J$.Ru('x');} J$.R( ... ) // read undefined But since read x operation maybe used as an expression, and try-catch (eval('try{x}catch(e){J$.Ru();}'), J$.I(typeof x === 'undefined' ? // read undefined I have implemented it in the frontend, works well so far. Best, On Wed, Dec 11, 2013 at 2:23 PM, Manu Sridharan [email protected]:
Liang Gong |
Sorry, after instrumentation it should look like this: On Wed, Dec 11, 2013 at 2:56 PM, Liang Gong [email protected] wrote:
Liang Gong |
@JacksonGL that would probably work fine to test for undeclared variables. However, I'd be a bit concerned that inserting Have you implemented a complete fix to this issue, including Koushik's case with variables declared during record but not replay? |
So far I tried on some websites using Firefox browser. I did not try for Here is the code in case someone is interested in trying that for record function wrapReadWithUndefinedCheck(node, name) {
"=" + RP + "3))",
also need to add the following code into analysis.js function Ru() { and this at the end of the file: Best, On Wed, Dec 11, 2013 at 3:03 PM, Manu Sridharan [email protected]:
Liang Gong |
Hi, I just found another issue. Need to check if the variable is used with Best, On Wed, Dec 11, 2013 at 3:16 PM, Liang Gong [email protected] wrote:
Liang Gong |
Yes, you need to remember this case as well. On Dec 11, 2013, at 4:13 PM, Liang Gong [email protected] wrote:
|
Fix the "typeof x" issue (at least for frontend), There are six changes in the esnstrument.js file attached. Changes are var z = xxx; will be transformed into: var z = J$.W(9, 'z', (eval('try{xxx}catch(e){J$.Ru("xxx");}'), J$.I(typeof Best, On Wed, Dec 11, 2013 at 4:24 PM, ksen007 [email protected] wrote:
Liang Gong |
@JacksonGL I don't think Github preserves attachments to emails regarding issues. The best thing for showing us your changes would be for you to (1) fork Jalangi, (2) create a branch with your changes in the fork, and (3) open a pull request for the branch. |
Thanks for the suggestion. I forked the project and commit my changes which https://github.com/JacksonGL/jalangi/commit/c14a9e99c53341680d743ec90953bbc281e98e0a All python scripts/sym.py tests passed. Best, On Wed, Dec 11, 2013 at 8:26 PM, Manu Sridharan [email protected]:
Liang Gong |
I added a couple of comments to the commit. We need to run on all tests, including some browser tests, before merging back. |
New update is herehttps://github.com/JacksonGL/jalangi/commit/7ed5eb94d56d348cc973ec3c38eb46ffdf5f24ccto Best, On Thu, Dec 12, 2013 at 9:17 AM, Manu Sridharan [email protected]:
Liang Gong |
an alternative solution for #19: var z = xxx; will be transformed into: var z = J$.W(9, 'z', (function () {try {xxx;} catch (e) {J$.Ru('xxx');}}(), var y = J$.W(17, 'y', J$.U(6, 'typeof', J$.I(typeof x === 'undefined' ? x = var z1 = J$.W(29, 'z1', J$.U(14, 'typeof', J$.B(10, '+', (function () {try Changes are herehttps://github.com/JacksonGL/jalangi/commit/5112b65f1fcf843fe6949cc6bbeb7b9214ac10fe. tests/unit/monkeypatch failed /home/jacksongl/JacksonGL_Ubuntu_Workspace/research/jalangi/github_myversion/jalangi/src/js/analysis.js:699 /home/jacksongl/JacksonGL_Ubuntu_Workspace/research/jalangi/github_myversion/jalangi/tests/unit/monkeypatch---- Recording execution of /home/jacksongl/JacksonGL_Ubuntu_Workspace/research/jalangi/github_myversion/jalangi/tests/unit/monkeypatch---- Replaying /home/jacksongl/JacksonGL_Ubuntu_Workspace/research/jalangi/github_myversion/jalangi/tests/unit/monkeypatchNone Best, On Thu, Dec 12, 2013 at 4:39 PM, Liang Gong [email protected] wrote:
Liang Gong |
@JacksonGL re: the test failure, do you invoke toString() on any objects directly in your new code? The test is checking what happens if the client program overwrites Object.prototype.toString(). If you need to invoke toString(), you need to stash away a pointer to it and use that pointer to invoke it. |
It seems that there is no explicit call of toString. I re-factored the Best, On Fri, Jan 3, 2014 at 1:34 PM, Manu Sridharan [email protected]:
Liang Gong |
We should think about preserving the ReferenceError that is thrown when reading an undefined variable. Right now, under Jalangi instrumentation, the error is no longer thrown. See existing unit test
tests/unit/reference_error.js
. We should also handle such errors thrown by a call toeval
, e.g.:(The above is checked in as
tests/unit/eval_undefined_var.js
.) Not preserving ReferenceErrors is causing a jQuery unit test to fail when jQuery is Jalangi-instrumented.The text was updated successfully, but these errors were encountered: