IZ 167551: Can not run application in Output Window using cygwin tool collection

Andrew Krasny <[email protected]>
Newsgroups gmane.comp.java.netbeans.reviewers
Message-ID <[email protected]>
Description of the bug (including IZ #)
---------------------------------------

Steps to reproduce:
- set cygwin tool collection as default
- create Welcome sample
- set Output window as Console type
- run the application
Result: Run fails with the following message:
     181 [main] welcome_8 4436
C:\Users\ap153252\Documents\NetBeansProjects\Welcome_8\dist\Debug\Cygwin-Windows\welcome_8.exe: 
*** fatal error - error
while loading shared libraries: /cygdrive/C/Program\ Files/NetBeans\
6.7/dlight1/bin/nativeexecution/Windows-x86/unbuffer.dll: cannot open 
shared object file: No such file or directory

RUN FAILED (exit value 256, total time: 217ms)




Impact assessment i.e. why it is a showstopper?
-----------------------------------------------

User just cannot start his application with I/O being redirected to the 
OutputWindow (in case when Cygwin is used for code compilation)


Risk assessment i.e. why is it safe?
------------------------------------

We use LD_PRELOAD to preload a small library that does unbuffering of 
user's application output. This is done when user uses OutputWindow only.
The problem that we faced with is that when a program is compiled with 
cygwin's compilers it requires the path to the library be in a cygwin 
notation (/cygdrive/c/... ). This is from the one hand, but from the 
other hand library loading fails if spaces in the path to the library 
are backslashed.

There is the only place where the behavior is as described.
For converting paths from Windows' notation to a Cygwin's one a common 
function is used. This function also adds slashes before spaces.

Proposed (hot) fix is to remove added slashes before assigning a path to 
LD_PRELOAD variable.

This is safe, because normally Window's files/directories cannot contain 
'\' as a part of name.



Confirmation of peer code review and QE verification of fix
------------------------------------------------------------

Confirm.


Changeset info (for reviewing diffs)
------------------------------------

      1.1 --- 
a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/UnbufferSupport.java
      1.2 +++ 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/UnbufferSupport.java
      1.3 @@ -160,6 +160,11 @@
      1.4                              new File(unbufferPath, 
unbufferLib).getAbsolutePath(); // NOI18N
      1.5
      1.6                      ldPreload = 
CommandLineHelper.getInstance(execEnv).toShellPaths(ldPreload);
      1.7 +
      1.8 +                    // HotFix: 167551 - Can not run 
application in Output Window using cygwin tool
      1.9 +                    // The problem is that it is wrong to 
escape path here...
     1.10 +                    // The hot fix is to "unescape" it back...
     1.11 +                    ldPreload = ldPreload.replaceAll("\\\\ ", 
" "); // NOI18N
     1.12                  } else if (isMacOS) {
     1.13                      // TODO: FIXME (?) For Mac and Windows 
just put unbuffer
     1.14                      // with path to it to 
LD_PRELOAD/DYLD_INSERT_LIBRARIES
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.