This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 231782 - Infinite recursion in JsIndexer causing OOM.
Summary: Infinite recursion in JsIndexer causing OOM.
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: Petr Pisl
URL: https://netbeans.org/projects/profile...
Keywords:
: 231363 231690 231884 232806 (view as bug list)
Depends on:
Blocks: 231322
  Show dependency tree
 
Reported: 2013-06-25 13:52 UTC by Tomas Zezula
Modified: 2014-03-06 01:14 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
elfinder.min.js (130.93 KB, text/plain)
2013-06-25 13:58 UTC, Tomas Zezula
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Zezula 2013-06-25 13:52:42 UTC
Seems that JS model may contain cycles causing the JSIndexer to enter an infinite recursion. See the attached heapdump.
Comment 1 Tomas Zezula 2013-06-25 13:57:54 UTC
The infinite recursion also occurs when you try to open the elfinder.min.js (attached) in editor (not sure if it's the same problem or separate issue).
Comment 2 Tomas Zezula 2013-06-25 13:58:42 UTC
Created attachment 136277 [details]
elfinder.min.js
Comment 3 Tomas Hurka 2013-06-25 14:00:57 UTC
Heap dump is available here: <https://netbeans.org/projects/profiler/downloads/download/Heapdumps/heapdump_231782.zip>
Comment 4 Tomas Zezula 2013-06-27 07:32:26 UTC
*** Bug 231884 has been marked as a duplicate of this bug. ***
Comment 5 Petr Hejl 2013-06-27 09:39:40 UTC
This one might be duplicate: #231782.
Comment 6 Petr Hejl 2013-06-27 12:16:35 UTC
There are three cycles in the model.
elFinder.prototype.debug.d.d references elFinder.prototype.debug.d
elFinder.prototype.notify.e.e references elFinder.prototype.notify.e
window.elFinder.clipboard.clipboard reference window.elFinder.clipboard
Comment 7 Petr Hejl 2013-06-27 13:42:10 UTC
I think the cause is on line 644 of formatted js:

        }, debug: function(b, c) {
            var d = this.options.debug;

In model the problem lies in ModelUtils:392 (btw it is a bit ugly to change model form type resolution imo).

Looks like this.options.debug is resolved to the outer debug and thus the cycle. I would say it is wrongly resolved, but I might be wrong. The code is too complex.

Safety catch would be to modify ModelUtils:391 from "if (function != null) {" to "if (function != null && function != object.getParent()) {"
Comment 8 Petr Hejl 2013-06-27 13:43:36 UTC
Perhaps the catch should be there anyway as it is imo pointless to create such one level cycle even if it would be in the source.
Comment 9 Petr Pisl 2013-06-27 20:28:47 UTC
There is more problems. The objects that are stored more times are:

elFinder.prototype.debug.d
elFinder.prototype.debug.arguments
elFinder.prototype.notify.f
elFinder.prototype.notify.g
elFinder.prototype.notify.d
elFinder.prototype.notify.e
elFinder.prototype.notify.arguments
elFinder.prototype.notify.c
elFinder.prototype.notify.l
elFinder.prototype.notify.j
elFinder.prototype.notify.k
elFinder.prototype.notify.h
elFinder.prototype.notify.i
window.elFinder.path2array
window.elFinder.shortcuts
window.elFinder.diff
window.elFinder.hide
window.elFinder.file
window.elFinder.selectedFiles
window.elFinder.getUI
window.elFinder.option
window.elFinder._commands
window.elFinder.D
window.elFinder.E
window.elFinder.F
window.elFinder.G
window.elFinder.A
....


Another problem is that the parameters generate the fqn as objects inside the functions, so there can be two objets with the same fqn, like if you have 

method : function (d) {
var d = d || expression. 
}

can lead to the inconsistency in the model.
Comment 10 Petr Pisl 2013-06-28 08:22:44 UTC
And Petr H. is right. There was also bug in the resolveSemiTypeChain method.
Comment 11 Petr Pisl 2013-06-28 08:55:47 UTC
Fixed in web-main: http://hg.netbeans.org/web-main/rev/dcc5fff1dbaa

Thanks to Petr H. for his contribution.
Comment 12 Petr Hejl 2013-06-28 09:41:39 UTC
Petre I think it would also useful to add a model test for this issue (model golden file).
Comment 13 Petr Pisl 2013-06-28 10:31:55 UTC
I agree. Added : http://hg.netbeans.org/web-main/rev/f3a5f6fdb8e7
Comment 14 Quality Engineering 2013-07-01 15:55:54 UTC
Integrated into 'main-silver', will be available in build *201307011244* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/dcc5fff1dbaa
User: Petr Pisl <ppisl@netbeans.org>
Log: #231782 - Infinite recursion in JsIndexer causing OOM.
Comment 15 Petr Hejl 2013-07-03 13:53:21 UTC
*** Bug 231363 has been marked as a duplicate of this bug. ***
Comment 16 pmaselkowski 2013-07-17 07:11:41 UTC
*** Bug 232806 has been marked as a duplicate of this bug. ***
Comment 17 Petr Hejl 2013-07-23 13:34:13 UTC
*** Bug 231690 has been marked as a duplicate of this bug. ***
Comment 18 kprovance 2014-03-06 01:14:32 UTC
Say my IDE is up to date and am geting this error, so, not fixed?