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.
Steps to reproduce: - create Quote sample project - build the project - set in project properties "Console Type" to "Output Window" - run the project - while the project is running try to cance it via Quote_1(Build, Run) progress bar Result: Multiple warning windows appear without content then IDE hangs.
I'm having trouble reproducing this one. I tried Quote and IO (both interactive apps) running in output window on both Windows XP and Windows Vista (and Mac OS X) and didn't see the hang. Everything worked as expected. During development of this feature I tested interactive apps many time running i output window and never experienced any hangs. It doesn't mean that there isn't a problem though, just that I cannot reproduce it. Can you please try again (after rebooting your machine) and attach stack trace and perhaps screenshot of the warnings. Who outputs them? Can you also try on other XP machines to see if the problem is local to your machine or if it happens on other machines as well.
Indeed when I tried to reproduce it recently I could do it only from the second attempt on my laptop and could not reproduce at all on another desktop. I found in the message.log msg Caused: java.nio.channels.ClosedChannelException at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:91) at sun.nio.ch.FileChannelImpl.force(FileChannelImpl.java:352) at org.netbeans.core.output2.FileMapStorage.flush(FileMapStorage.java:351) [catch] at org.netbeans.core.output2.OutWriter.flush(OutWriter.java:419) at java.io.PrintWriter.flush(PrintWriter.java:276) at org.netbeans.modules.cnd.execution.NativeExecution$OutputReaderThread.run(NativeExecution.java:210) ALL [null]: Problem writing to output file SEVERE [global] message.log and screenshot are attached
Created attachment 59510 [details] messages.log zip
Created attachment 59511 [details] jvm stack
Created attachment 59512 [details] screenshot
I can now reproduce in a debug environment on Windows Vista. Here is what I think is happening: CND reads output from the pplication process character by character until stream is empty or there is an I/O error. For each character it calls NB's output.write() and output.flush(): OutWriter (NetBeans) public synchronized void flush() { if (checkError()) { return; } try { getStorage().flush(); if (lines != null) { lines.fire(); } } catch (IOException e) { handleException (e); } } NativeExecution (CND) public void run() { try { int read; while ((read = err.read()) != (-1)) { if (read == 10) output.write("\n"); // NOI18N else output.write((char) read); output.flush(); } output.flush(); } catch (IOException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } } After canceling a processwriting to o flushing output may no longer work but output.flush() silently handles the IO exception (in hadleException()), displays a dialog but never rethrows the exception so the loop keep going. What the root cause is is difficult to say. OutWriter should rethrow the exception. It would solve the problem. But I don't think CND is stopping all threads and processes and closing all streams in the right order which would probably also solve the problem. I tried many different things in CND but most of my attempts made the situation worse and I don't have a safe and simple solution. Instead I have implemented a flags that gets set if the user cancels the execution and will cause the loop to break. It is very safe and does solve the issue with the hang and multiple dialogs but it doesn't solve the deeper problem. I will have QA test before committing the change.
Escalated to P1.
Alexander. : I tried your fix and it seems to be working fine. At least I did not observe neither hang nor warnings on both IO and Quote. I believe your fix should be integrated into NB6.1.
changeset 596e59a7beea in main details: http://hg.netbeans.org/main?cmd=changeset;node=596e59a7beea description: 131739 Cancel running task hangs IDE on Windows changeset ec7f20533a93 in main details: http://hg.netbeans.org/main?cmd=changeset;node=ec7f20533a93 description: 131739 Cancel running task hangs IDE on Windows
I missed this while testing the patch because it was not highly visible but now I have realized that quote processes are not killed when user cancels running. They are shown as working in "Task Manager" and even we can attach to them to debug from IDE. The last can mislead a user if he/she tries to debug Quote and runs it once again. Moreover sometimes these processes continue working after closing IDE and then they take up to 50% of processor time (probably because IDE is trying to kill them and I realized the problem because of that). So I think this issue needs additional investigation before committing a fix into 6.1 branch.
Changes pushed to 6.1. I see your comment just now..... As I said in an earlier comment, this fix is not a fix for all problems with canceling a running process. It is only meant to prevent the hang and to avoid the multiple dialogs which was what this bug was about. By looking at the code the other day, I see not all threads are correctly stopped or all streams correctly closed and it is also possible that the running process is not correctly stopped. I tried many things but all attempts failed and several caused hangs so I concluded that now is not the time to try and fix this. A fix would affect everytime you ran a projects and would require extensive testing on many different platforms. The 'fix' I made for this issue (131739) affects only code when you cancel so it is very low risk. I suggest you file a new (p2) bug regarding the still-running process and I can take another look. Please provide enough info so I can reproduce it. I will close this IZ as Fixed.
verified in NB6.1 build 200804040802
I can still reproduce the problem with canceling on Solaris. Here is messages.log: ALL [null]: Problem writing to output file SEVERE [global] msg Caused: java.nio.channels.ClosedChannelException at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:89) at sun.nio.ch.FileChannelImpl.force(FileChannelImpl.java:350) at org.netbeans.core.output2.FileMapStorage.flush(FileMapStorage.java:351) [catch] at org.netbeans.core.output2.OutWriter.flush(OutWriter.java:419) at java.io.PrintWriter.flush(PrintWriter.java:270) at org.netbeans.modules.cnd.execution.NativeExecution$OutputReaderThread.run(NativeExecution.java:215) ALL [null]: Problem writing to output file SEVERE [global] I think the problem is Thomas fix is not quite full: It should check cancel variable after while() loop, as flush() is invoked once more and can throws (and I can see it now) IOException which can lead to hang of my Solaris machine.
Possible fix with http://hg.netbeans.org/main/rev/d43b7e961a15. The IOE shouldn't happen but I don't know about the hang as neither Thomas nor I have been able to duplicate that part. I've sent an updated jar file to Maria for her to test in Sun Studio. If she can no longer get it to hang I'll mark the bug fixed.
The fix above appears to have fixed both the IOE (expected) and hang (hoped for). Per email from Maria: > Thanks a lot for the fix! I have tested it on my Solaris machine and it looks > that now I can cancel the running process without hang and exceptions. Closing as fixed.
Gordon, I was able to reproduce this again with the latest fix you sent to me. It looks like we have the following situation: in while loop we are still not canceled, and then we are canceled and flush() is invoked. looks like some sync problems are still in place. the same message as it was before in messages.log: msg Caused: java.nio.channels.ClosedChannelException at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:89) at sun.nio.ch.FileChannelImpl.force(FileChannelImpl.java:350) at org.netbeans.core.output2.FileMapStorage.flush(FileMapStorage.java:351) [catch] at org.netbeans.core.output2.OutWriter.flush(OutWriter.java:419) at java.io.PrintWriter.flush(PrintWriter.java:270) at org.netbeans.modules.cnd.execution.NativeExecution$OutputReaderThread.run(NativeExecution.java:215) ALL [null]: Problem writing to output file SEVERE [global]
Maria, was this still on Solaris? If so, was it S10 or an older version. Also, single or multi-cpu?
Solaris: uname -a SunOS masha 5.11 snv_79a i86pc i386 i86pc 1 proc
Marking as fixed per email from Maria and Alexander.
verified in sstrunk build based on NB6.1 with provided jar file.
fix backported into release61_fixes branch changeset: 77533:be7dcc3ac528