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 83883 - NPE in gdb.EditorContextBridge.annotate()
Summary: NPE in gdb.EditorContextBridge.annotate()
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: _ gordonp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-31 10:45 UTC by Nikolay Molchanov
Modified: 2009-06-25 10:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Molchanov 2006-08-31 10:45:53 UTC
I was testing a fix for IZ 83830 (IAE when using a Function Breakpoint)
and noticed another problem. If my project is located in directory with 
spaces, there is NPE in EditorContextBridge.annotate():

java.lang.NullPointerException
    at
org.netbeans.modules.cnd.debugger.gdb.EditorContextBridge.annotate(EditorContextBridge.java:129)
    at
org.netbeans.modules.cnd.debugger.gdb.CurrentThreadAnnotationListener$3.run(CurrentThreadAnnotationListener.java:230)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:493)
[catch] at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:926)


    public static Object annotate(CallStackFrame csf, String annotationType) {
        String fullname = csf.getFullname();
        if (fullname != null) {
            File file = new File(csf.getFullname());
            FileObject fo = FileUtil.toFileObject(file);
            String url;
            try {
129             url = fo.getURL().toExternalForm();
            } catch (FileStateInvalidException ex) {
                /* Best guesses */
                if (Utilities.isWindows()) {
                    url = "file:/" + fo.getPath().replace(" ", "%20"); // NOI18N
                } else {
                    url = "file:" + fo.getPath(); // NOI18N
                }
            }

The root of the problem is that "fullname" is not correct:

fullname = (java.lang.String)G:/Documents and
Settings/nik/MP1//usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iostream

As a result "file" is also not correct:

file = (java.io.File)G:\Documents and
Settings\nik\MP1\usr\lib\gcc\i686-pc-cygwin\3.4.4\include\c++\iostream

And obviously "fo" becomes "null":

fo = null

I don't know how fullname got this strange value. This is a sample MP1 project. 
I set several "toggle" breakpoints inside main() and "function" breakpoint 
on main(); then I start debugging and press "Continue" 1 or 2 times, and 
NPE happens.
Comment 1 _ gordonp 2006-09-13 19:58:09 UTC
A related fix I've been working on (IZ82103) should also fix this.
Comment 2 julieg 2006-09-13 22:59:40 UTC
According to the FCS quality criteria, NPE is a P1 bug.
Comment 3 _ gordonp 2006-09-14 00:22:25 UTC
There were 2 problems here. First off, the project rundir was being prepended
to unix-like paths sent back from gdb. Hence the paths like "G:\Documents and
Settings\nik\MP1\usr\lib\gcc\i686-pc-cygwin\3.4.4\include\c++\iostream".

Besides that, we were assuming the file existed and tried to get information
only available when it did exist. So in cases where it didn't, we got an NPE.

The fix is to not prepend the rundir to unix-like absolute paths and to check
for file existance before trying to annotate.
Comment 4 Alexander Pepin 2007-09-18 15:07:03 UTC
Verified in nightly build 20070915