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 194826 - The code model can become corrupt, causing false errors
Summary: The code model can become corrupt, causing false errors
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 7.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-28 22:21 UTC by tbrunhoff
Modified: 2011-03-02 21:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
desktop snapshot (152.89 KB, image/png)
2011-02-07 22:22 UTC, tbrunhoff
Details
log of ide session (49.22 KB, application/octet-stream)
2011-02-07 22:24 UTC, tbrunhoff
Details
dump of c++ code model (2.50 MB, application/x-gzip)
2011-02-07 22:27 UTC, tbrunhoff
Details
unresolving of obvious id (120.77 KB, image/png)
2011-02-08 20:07 UTC, Alexander Simon
Details
unresolving of obvious id (with visible main in navigator) (121.73 KB, image/png)
2011-02-09 21:01 UTC, Alexander Simon
Details
event #2: snapshot (204.71 KB, image/png)
2011-02-11 20:07 UTC, tbrunhoff
Details
event #2: ide log (671.61 KB, application/octet-stream)
2011-02-11 20:08 UTC, tbrunhoff
Details
event #2: dump of c++ code model (5.06 MB, text/plain)
2011-02-11 20:11 UTC, tbrunhoff
Details
event #3: snapshot (190.35 KB, image/png)
2011-02-17 20:00 UTC, tbrunhoff
Details
event #3: ide log (48.01 KB, application/octet-stream)
2011-02-17 20:02 UTC, tbrunhoff
Details
event #3: dump of c++ code model (2.24 MB, text/plain)
2011-02-17 20:03 UTC, tbrunhoff
Details
project/libraries from last model dump (1.20 KB, text/plain)
2011-02-18 10:45 UTC, Alexander Simon
Details
simplified example of wrong resolving (7.96 KB, application/x-gzip)
2011-02-18 11:50 UTC, Alexander Simon
Details
more complex sample (103.50 KB, application/x-tar)
2011-02-28 11:52 UTC, Vladimir Voskresensky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tbrunhoff 2011-01-28 22:21:58 UTC
Today I had the following code:

    bool TlFader::finalize()
    {
        uint nFound  = 0;
        ...

and the ide showed a persistent error that nFound could not be resolved. I tried:
 - changing the name to nFoundx
 - moving after other declarations
 - adding other assignments to nFound

Yet nothing got rid of the error until I stopped the ide, removed ~/.netbeans/dev/var/cache/cnd/model, and then it went away.

I should note that, prior to this, netbeans/java were crashing and hanging, and I was installing, removing and reinstalling everything related to java. So perhaps it became corrupt in the process.
Comment 1 Alexander Simon 2011-02-01 15:20:16 UTC
There are no chance to investigate issue without IDE log and/or steps to reproduce.
Comment 2 Alexander Simon 2011-02-02 12:52:17 UTC
I hope that change set:
http://hg.netbeans.org/cnd-main/rev/9413ea8fedc4
fixes bug.

You interested which additional information you can provide for such bugs:
- the best is steps to reproduce
- log of current IDE session
- context project menu->Code Assistance->Dump C/C++ Code Model Diagnostic. Select "Cache of xRef for file", "File Code Model", "Preprocessor States", "General File Information".
Comment 3 Quality Engineering 2011-02-03 05:53:21 UTC
Integrated into 'main-golden', will be available in build *201102030000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9413ea8fedc4
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixing Bug #194826 -  The code model can become corrupt, causing false errors
Comment 4 tbrunhoff 2011-02-07 22:21:40 UTC
Sorry... not fixed. Attached is a snapshot from an editing session just after starting up the ide (build 201102070000). There are a number of errors showing in the ide that should not be there. The events leading up to this probably include the following, in order:
 - long running editing session with build 201101271430
 - many changes in the code tree made externally by 'svn up'
 - exit ide
 - install and run 201102070000
 - another external change made to the file shown in the snapshot
 - errors appear as shown in the snapshot
Comment 5 tbrunhoff 2011-02-07 22:22:24 UTC
Created attachment 105712 [details]
desktop snapshot
Comment 6 tbrunhoff 2011-02-07 22:24:11 UTC
Created attachment 105713 [details]
log of ide session
Comment 7 tbrunhoff 2011-02-07 22:27:02 UTC
Created attachment 105714 [details]
dump of c++ code model
Comment 8 tbrunhoff 2011-02-08 18:44:12 UTC
Alexander, I get this condition all the time, so I can certainly attach more instances or get other info. I should note that sometimes these syntax errors that appear in the ide are caused by a (very long) lag time between a change in the code and the re-parsing catching up. I wonder if this could be caused by a race condition, where the parser thinks he is all caught up with the changes, but it isn't. Is there a way to force the ide to reparse?
Comment 9 Alexander Simon 2011-02-08 19:20:03 UTC
(In reply to comment #8)
> Is there a way to force the ide to reparse?
Yes:
- select all open projects (for NB6.9 only)
- context project menu->Code Assistance->reparse
Comment 10 Alexander Simon 2011-02-08 20:06:40 UTC
reproducible on samples (for example Fractal), steps to reproduce:
- edit Mandelbrot function (for example type "uint i;" before while loop)
- sometimes unresolved is appeased and do not go away
see attachment.
Comment 11 Alexander Simon 2011-02-08 20:07:43 UTC
Created attachment 105750 [details]
unresolving of obvious id
Comment 12 Alexander Simon 2011-02-09 21:01:36 UTC
Created attachment 105803 [details]
unresolving of obvious id (with visible main in navigator)
Comment 13 Vladimir Voskresensky 2011-02-10 10:02:10 UTC
insert IdentifierErrorProvider:142 the following
                    System.err.println("Unresolved REF " + ref);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                        Exceptions.printStackTrace(ex);
                    }
and you will see stable instability
Comment 14 Quality Engineering 2011-02-10 11:30:10 UTC
Integrated into 'main-golden', will be available in build *201102100500* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/97702c253b4d
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: add fix for #194826 -  The code model can become corrupt, causing false errors
Comment 15 Alexander Simon 2011-02-11 17:20:26 UTC
Additional fix:
http://hg.netbeans.org/cnd-main/rev/775736b418f1
Comment 16 tbrunhoff 2011-02-11 17:53:35 UTC
I must say that my impression with 201102100500 is that I see far fewer errors in the editor. Much improved!
Comment 17 Alexander Simon 2011-02-11 18:54:26 UTC
(In reply to comment #16)
> I must say that my impression with 201102100500 is that I see far fewer errors
> in the editor. Much improved!
Thanks.
It would be nice understand following:
- in which condition error appeared
- is errors disappeared after document saved/typing space
- check what shows references cache in Code Assistance->Dump...->Cache...
Comment 18 tbrunhoff 2011-02-11 19:57:46 UTC
Here's another I ran into using build 201102100500. This one popped up when I created a new c++ project from existing sources. Attachments to follow.
Comment 19 tbrunhoff 2011-02-11 20:07:12 UTC
Created attachment 105899 [details]
event #2: snapshot
Comment 20 tbrunhoff 2011-02-11 20:08:12 UTC
Created attachment 105900 [details]
event #2: ide log
Comment 21 tbrunhoff 2011-02-11 20:11:27 UTC
Created attachment 105901 [details]
event #2: dump of c++ code model
Comment 22 tbrunhoff 2011-02-11 20:29:05 UTC
event #2 notes:
 - forcing a reparse did not change the state
 - I then closed all projects and reopened the one project that (I thought) had the problem, and the errors in the editor were gone. Note that some of the other projects that were open shared the include file that had the error (mediainfo.h).
Comment 23 Quality Engineering 2011-02-16 11:40:46 UTC
Integrated into 'main-golden', will be available in build *201102160501* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c0cf94d06ec8
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixing Bug #194826 -  The code model can become corrupt, causing false errors
- cancel reference visitor on cancel request
- clear file references context on file parsing finished
Comment 24 Quality Engineering 2011-02-17 11:00:47 UTC
Integrated into 'main-golden', will be available in build *201102170501* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/2aca78f5502c
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixing Bug #194826 The code model can become corrupt, causing false errors
- reparse: do not clean libraries that are used in other projects
- fix broken library manager (broken after introducing file system in library key)
Comment 25 tbrunhoff 2011-02-17 19:57:36 UTC
I have another instance. I can't tell if this is the same bug or a different one, but I'm pretty sure this has to do with the influence of other open projects.

The problem: members of a structure appear undefined in the ide editor.

The structure: The declarations are arranged as follows:
-------- header.h ------------
class Foo {
private:    struct FooImpl& m; // note that its not defined here
public:     Foo();
            ~Foo();
            void operate();
};
-------- main.cpp -------------
#include "header.h"

struct FooImpl {
    FooImpl() : member1(1), member2(false) {}
    int member1;
    bool member2;
};

Foo::Foo() : m(new FooImpl()) {}
void Foo::operate() { m.member1++; m.member2 = true; }
------------------------------

If I put this into a new project, everything is fine... no errors in the editor. In my environment, declarations similar to these appear in a single project, but m.member1 and m.member2 are marked as undefined in the editor. This is complicated by the fact that the errors will appear if I open other projects in a certain order, and if I close all the other projects and tell the ide to reparse, the errors go away.

My projects are as follows:
 - audio.nb
 - include.nb
 - media.nb
 - mediaapi.nb (this is the one with the problem)
 - mediareader
 - mxf.nb
 - obuf.nb
 - ommedia_python.nb
 - utils.nb
 - utils2.nb

Here is one scenario:
 1. close all projects
 2. open mediaapi.nb (no errors)
 3. open all other projects above (no errors)
 4. close mediaapi.nb
 5. reopen mediaapi.nb (**errors appear in the editor**)
 6. close all projects except for mediaapi.nb and reparse (errors disappear)

Snapshot, ide log and code model attached below.
Comment 26 tbrunhoff 2011-02-17 20:00:59 UTC
Created attachment 106125 [details]
event #3: snapshot
Comment 27 tbrunhoff 2011-02-17 20:02:02 UTC
Created attachment 106126 [details]
event #3: ide log
Comment 28 tbrunhoff 2011-02-17 20:03:40 UTC
Created attachment 106127 [details]
event #3: dump of c++ code model
Comment 29 tbrunhoff 2011-02-17 20:08:40 UTC
The classes in mediaapi.nb and the code snippet above are isomorphic. Here are the equivalences:
 - Foo == OmMovie
 - FooImpl& Foo::m == MovieImpl& OmMovie::m
 - Foo::m.member1 == OmMovie::m.obj

...and so forth.
Comment 30 Alexander Simon 2011-02-18 10:42:42 UTC
Todd,
I see some problem in your projects.
1. Some projects have a broken includes. If you want to rely on code model you should fix all broken include directives.
2. Project "include.nb" exists in two ways:
- as NB project
- as library project (created automatically for mediaapi.nb)
To right model you should:
- remove "include.nb" from projects
- or set "include.nb" as required project for mediaapi.nb and open mediaapi.nb with required projects

About  reparsing. Your scenario is:
1. close all projects
2. open mediaapi.nb (no errors)
Automatically created library for path "home/toddb/src/src1/omneon/shared/include".
3. open all other projects above (no errors)
It's a problem. Changing "mediaapi.nb" can result in conflict between library "home/toddb/src/src1/omneon/shared/include" and project " and project "include.nb".
4. close mediaapi.nb
5. reopen mediaapi.nb (**errors appear in the editor**)
Conflict between library "home/toddb/src/src1/omneon/shared/include" and project " and project "include.nb".
6. close all projects except for mediaapi.nb and reparse (errors disappear)
Library "home/toddb/src/src1/omneon/shared/include" is up to date.
Comment 31 Alexander Simon 2011-02-18 10:45:01 UTC
Created attachment 106144 [details]
project/libraries from last model dump
Comment 32 Alexander Simon 2011-02-18 11:50:53 UTC
Created attachment 106145 [details]
simplified example of wrong resolving

m.member1 and m.member2 do not resolved
Comment 33 Vladimir Voskresensky 2011-02-28 11:52:54 UTC
Created attachment 106540 [details]
more complex sample

I've attached archive with the following structure:
- media_header project
- media project (impl 1) with dependency on media_header
- media2 project (impl 2) with dependency on media_header
Comment 34 Vladimir Voskresensky 2011-02-28 12:00:10 UTC
Todd, I've made a change to track situations with separated impl && declaration parts.
http://hg.netbeans.org/cnd-main/rev/d0e5c465b0c2

Can you check dev build with the fix?
Comment 35 Quality Engineering 2011-03-01 17:50:53 UTC
Integrated into 'main-golden', will be available in build *201103011142* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/d0e5c465b0c2
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: fixing #194826 -  The code model can become corrupt, causing false errors
- unresolved types resolve again
Comment 36 Vladimir Voskresensky 2011-03-02 21:44:02 UTC
Several issues were fixed in the context of this one.
Todd, let's consider this issue fixed and for other known issues, please, open new one to not mix with this.