Closed LucaFranceschini closed 5 years ago
Hi Luca,
I can't exactly what triggers the recursion, but the builtin callbacks are tricky to work with. As a workaround, avoid using console.log
inside builtinEnter
/Exit
, e.g. just defer your logging:
// DO NOT INSTRUMENT
(function (sandbox) {
function MyAnalysis() {
var builtins = [];
this.builtinEnter = function (name, f, dis, args) {
builtins.push(name);
};
this.endExecution = function () {
console.log(builtins);
}
}
sandbox.addAnalysis(new MyAnalysis(), {includes:"<builtin>,enterExit.js,exitException"});
})(J$);
@alexjordan is right. The cause is about console.log
.
Although we have some bypass mechanism to avoid recursively instrumenting the code inside the Jalangi analysis, console.log internally uses process.nextTick to run some I/O in the next event loop which will use some built-in functions which triggers the built-in callback and results in an infinite recursion.
I will post a patch later today to solve this problem which can give you the ability to dump logs inside the builtin callback.
Thanks both of you for your prompt replies and patch!
I am trying to track down builtin function invocations with NodeProf. I am running NodeProf directly on GraalVM.
Consider the following program opening a file and then closing it:
And the following simple analysis printing
builtinEnter
events (written starting from one of the examples):The file program works fine when executed with node, but if I execute it as suggested in the tutorial with the following command:
The program at some point enters an endless recursion:
What am I missing?