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 230220 - Endless loop in AngularJsEmbeddingProviderPlugin.processController
Summary: Endless loop in AngularJsEmbeddingProviderPlugin.processController
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: AngularJS (show other bugs)
Version: 7.3
Hardware: PC Linux
: P1 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
: 230218 231138 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-05-24 09:34 UTC by _ tboudreau
Modified: 2013-06-15 03:03 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Stack trace (153.67 KB, text/plain)
2013-05-24 09:34 UTC, _ tboudreau
Details
Proposed fix. (904 bytes, patch)
2013-06-12 15:41 UTC, Tomas Zezula
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2013-05-24 09:34:08 UTC
Created attachment 134851 [details]
Stack trace

I think JDK 8 must allow deeper stacks because I have never seen a stack trace like the one I'm attaching.  It appears to be recursing endlessly on itself, and the IDE has been hung for 5 minutes.
Comment 1 Marek Fukala 2013-06-12 08:07:22 UTC
AngularJsEmbeddingProviderPlugin which is called from EmbeddingProvider for javascript content queries the JsIndex which calls QuerySupport.query() which then tries to update the index via javascript EmbeddingIndexer which requires the embedded js virtual source == cycle.

I'm not sure if it is allowed to access the index from an EmbeddingProvider, so passing to Tomas Zezula which should confirm that.

There's also some kind of caching of the JsIndex queries implemented in JsIndex, but in this case is apparently invalidated as the QuerySupport is called.

Tome, please take a look at the stack and tell us if we can do such call or not, thank you.
Comment 2 _ tboudreau 2013-06-12 08:22:36 UTC
Most, if not all, embedded JS expressions in HTML will be referencing members of the $scope variable (which the parser would have to synthesize somehow).

Angular embedding also allows expressions which are not quite legal Javascript, such as

<span ng-repeat="(key,value) in dictionary">

or filtering values ala

<span ng-model="item.created | date">

So, while the syntax highlighting is nice to have, it will either need some sort of enhanced embedded parser or other special handling.  Might be worth thinking about when solving this.

So given that much of the embedded js will be illegal, and the rest will reference members on a variable that isn't declared anywhere, it wouldn't be the worst idea to avoid trying to do anything too complex for these expressions.
Comment 3 Petr Pisl 2013-06-12 12:15:16 UTC
Tim, there is already some simple support of these expressions. It's implemented for ng-repeat for example.  

The problem that is now discussed here is more general. The solution would be probably to create somehow the virtual source without the knowledge about the properties of the controller.
Comment 4 Marek Fukala 2013-06-12 13:50:47 UTC
*** Bug 230218 has been marked as a duplicate of this bug. ***
Comment 5 Tomas Zezula 2013-06-12 15:33:00 UTC
The problem is in AngularJsEmbeddingProviderPlugin which calls the JsIndex.query().
The EmbeddingProviderPlugin is called during the creation of the index so such a call causes a recursion.
We can change the indexing to allow the Indexers (EmbeddingProviders, Parsers) to call to index however it's questionable they cannot see the data actually written just the last generation of the data which is probably not very useful.
Comment 6 Tomas Zezula 2013-06-12 15:40:23 UTC
*** Bug 231138 has been marked as a duplicate of this bug. ***
Comment 7 Tomas Zezula 2013-06-12 15:41:17 UTC
Created attachment 135707 [details]
Proposed fix.
Comment 8 Tomas Zezula 2013-06-12 15:46:34 UTC
I've attached patch allowing the indexers to do queries during index building. I am not sure if the query dome by the AngularJsEmbeddingProviderPlugin is intentional or not. If it is the attached patch should help.
Marku, can you test the patch?
Comment 9 Petr Jiricka 2013-06-12 16:37:33 UTC
Thanks for the investigation and the patch Tomas. Marek is on vacation until the end of the week - Petr P, can you please try this out?

BTW, is this a beta stopper? We may want to elevate this to P1.
Comment 10 Petr Pisl 2013-06-12 22:00:48 UTC
I'm going to look at this.
Comment 11 Petr Pisl 2013-06-13 07:14:00 UTC
Tome, with the patch I can not reproduce it. As the hot fix it could be ok. We don't need to store the right information in the index from the file, where it happened. For us is important to build the virtual source for code completion. So when the initial scan is done and in this time all other sources are already scanned. Anyway I will try to change the way how we generate the virtual source to don't use index in the future.

Tome are you going to apply the patch?
Comment 12 Petr Pisl 2013-06-13 07:15:54 UTC
After offline discussion with Tomas, assigning to Tomas.
Comment 13 Tomas Zezula 2013-06-13 07:54:14 UTC
Yes.
I am going to integrate it.
Comment 14 Tomas Zezula 2013-06-13 07:58:45 UTC
Fixed jet-main 4914c3f0ebf2
Comment 15 Petr Pisl 2013-06-13 08:07:02 UTC
Tomas thanks.
Comment 16 Petr Jiricka 2013-06-13 09:40:39 UTC
This bugfix did not make it before the branching of 7.4 beta, but IMO it is a beta stopper. Marian, what is the process, can it be merged to the beta branch?
Comment 17 Marian Mirilovic 2013-06-13 12:02:44 UTC
Yes, please do it ASAP. Thanks in advance.
Comment 18 Tomas Zezula 2013-06-13 17:17:10 UTC
Integrated 7.4 beta into http://hg.netbeans.org/releases/rev/f2472c9941bc
Comment 19 Quality Engineering 2013-06-14 00:49:38 UTC
Integrated into 'releases', will be available in build *201306132201* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/f2472c9941bc
User: Tomas Zezula <tzezula@netbeans.org>
Log: #230220:Endless loop in AngularJsEmbeddingProviderPlugin.processController
Comment 20 Quality Engineering 2013-06-15 03:03:48 UTC
Integrated into 'main-golden', will be available in build *201306142301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4914c3f0ebf2
User: Tomas Zezula <tzezula@netbeans.org>
Log: #230220:Endless loop in AngularJsEmbeddingProviderPlugin.processController