-
Notifications
You must be signed in to change notification settings - Fork 119
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
ES5 strict mode #120
Comments
We cannot support ES5 strict mode because Jalangi 2 uses arguments.callee which cannot be accessed in the strict mode. |
@ksen007 would a solution be to strip any use of |
Stripping "use strict" is still problematic in my case, because I am using Jalangi to instrument code in a webpage's <script type='module'> tag, which is forced to be a strict mode. If I change the tag's type to "text/javascript", the page suffers error because another tag cannot use exported functions from the non-module-typed <script> tag. . |
@gogo9th yes that is a tricky scenario. The only thing I can think of would be to make Jalangi's use of |
Thanks for your ideas. I think making |
I think J$ should have a hierarchical scope management object based on import & export declarations for each sid. |
Hi @gogo9th, to clarify, I was proposing to (optionally?) remove usage of
What problem is this solving? If it's not towards fixing handling of strict mode, I'd prefer to leave this to the analysis. |
Before you go too deep down this rabbit hole.. I know that @algobardo and @christofferqa also fought with Jalangi and modern EcmaScript features several years ago - perhaps they can drop a quick line about their endeavours? |
I wonder what's an example of this. If we meet a native function, we will not track inside it anyway, so there will be no additional problem we need to worry about, isn't it...? |
The problem is a native function calling back into a source-code function, e.g., anytime |
I came across a possible solution to this problem. In JS you can access the value of a function via its name. What if in Jalangi instrumentation, we introduced a generated name for any anonymous function, and then just always used the function name instead of |
I am very sorry for my late reply, I've found several more bugs/problems in Jalangi2 and have been fixing them. It took me about 100 hours, and I think I fixed all of them. I will organize them and tell you in the other thread we have been discussing. For your suggestion above, are you suggesting that whenever an anonymous function appears in the source code, we instrument the code such that we store the function's value in a generated name variable (in the global scope), and we replace |
One similar issue I was fixing was about with() statements. with() statement error: esnstrument.js sets Also, read & write callback should check if the variable belongs to some object in the Is using stacks for |
I'm sorry, but I was not clear why this would be a problem.. You're right that we cannot install a callback on a native function itself. Yet, we can simply skip the native function and install the callback in the source-code function. For example, if we have code like
, then we can instrument the contents of Meanwhile, I have a different concern about this |
@gogo9th thanks so much for all these great comments. Just an FYI that I am busy today and possibly tomorrow but I will give feedback here as soon as I can |
Sorry for all the bugs. Upstreaming your fixes would be great and very welcome!
I was actually suggesting adding a name for the function itself, rather than generating a variable. Do you think adding a name to anonymous functions is risky?
At a high level, this sounds reasonable to me, but I don't really know about all the corner cases that could crop up here. I am not really sure if the decision to skip support of
Why is this needed?
I am not sure. But isn't the approach of introducing names for anonymous functions a better solution?
Do you have an example here? |
We need this, because multiple
|
Jalangi has another issue with the strict mode. When we have a sample function:
Jalangi instruments this as follows:
Here, the line
I am actually not sure if we really need to above line in the instrumented code. Can we just remove this line by commenting out the
If a callback function has to change the contents of arguments, it can do it from withing the function-enter callback:
|
Tentatively I agree we can remove that callback that overwrites |
Thanks for the feedback. I am lastly working on making <script type='module'> and eval() work. For eval(), some modules (e.g., fs, esotope) use native functions, but if the target program redefines them, Jalangi can fall into an infinite loop. Therefore, Jalangi should make sure that all modules to be used while processing eval() should use unredefined original native functions. This can be done by parsing and transforming the source code of modules to use unmodified original native functions by using Babel. I have one question. Why doe Jalangi wrap each script or function code with a while loop? What could go wrong if they are just wrapped by a try-catch block without a while loop? |
This is to enable backtracking functionality. See slides 40--43 here: https://manu.sridharan.net/files/JalangiTutorial.pdf I think it'd be reasonable for you to disable that while loop instrumentation on a branch, if your analyses don't use it. Maybe we should add a flag to optionally disable it. |
For anyone still tracking this issue, I attempted to implement partial support for It will fail at runtime for some unusual cases involving getters / setters. And it's a real hack right now and needs cleanup. But if anyone has feedback let me know. |
I happened to meet in a situation that I could only run instrumented JS file in ES5 strict mode or ES6.
Since ES6 is currently unsupported, I use the former configuration.
However, assigning arguments is not allowed in strict mode but quite common in the instrumented JS file.
Is it possible to support ES5 strict mode? If yes, what changes are needed against Jalangi2 source code?
The text was updated successfully, but these errors were encountered: