-
Notifications
You must be signed in to change notification settings - Fork 17
Description
In the frames array of the API output, for each frame the API point to the function declaration in the bundle, for example, for the following bar function, the API would point to between “bar” and the “(“:
bar (){blabla.....}
^
The described behavior is different from the well known error callstack approach, where the error stack point to the line that was executing in a caller function when the callee function in the stack was called
So for example if we have the following code the error call stack would point to the call of bar inside the foo function:
bar (){blabla.....}
foo(){bar()}
------^
That causes a lot of issues in deobfuscation/unminification we are trying to tackle over the last year or so, as most open source deobfuscators are expecting the error call stack pattern, they fail to handle the current API output.
After discussions, there are 2 reasons the current output approach was chosen:
-
Space: Save space in the frames array by representing each function canonically, despite having multiple potential child stacks (i.e. with different callee locations).
For example, in the following code: foo(){bar(); bar();} in case the profiler sampled both call to bar, we would have 2 entries if we follow the error stack approach.Counter argument- while its a valid concern, there are few ideas on how we can compress the output size that were raised in this github repo, like: https://github.com/WICG/js-self-profiling/issues/74 We can also introduce a new flag to enable error stack approach. So it would be the consumer decision. Furthermore, while I understand the concern about the output size, I believe that in the common case consumers would prefer something that can be easily deobfuscated, even on the expense of the output size. -
Ambiguity: the output would point to different location for calling of the same function from different places.
For example, in the following code: foo(){bar(); bar();}
in case the profiler sampled both call to bar, we would have 2 entries with different line/column offset if we follow the error stack approach.Counter argument: Once we follow the error call stack approach deobfuscation becomes trivial and then this ambiguity concern vanish as after deobfuscation both frames would be "bar".