Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 53784 - Different results when running under debugger
Summary: Different results when running under debugger
Status: RESOLVED DUPLICATE of bug 40066
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Luc Bourlier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-04 13:31 EST by Brian Young CLA
Modified: 2006-12-18 15:19 EST (History)
5 users (show)

See Also:


Attachments
Testcase (3.66 KB, application/octet-stream)
2004-03-04 13:31 EST, Brian Young CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Young CLA 2004-03-04 13:31:01 EST
When I run a simple program, which I have attached to this report, under the 
debugger I get the desired results printed to the console.  

About to schedule task.
Task scheduled.
Please Enter 'e' + <Enter> to end task
Task begin
text/html
Task begin
text/html
Task begin
text/html
e
Task ended !

When I run the same program but NOT under the debugger I get unexpected output:

About to schedule task.
Task scheduled.
Please Enter 'e' + <Enter> to end task
Task begin
e
Task ended !


I am running with Sun JVM 1.4.2 the 3.0 M7 build.  I have tried running under 
Win2K and XP and get the same differing results.  Can you explain to me why the 
results are different?
Comment 1 Brian Young CLA 2004-03-04 13:31:44 EST
Created attachment 8336 [details]
Testcase
Comment 2 Darin Wright CLA 2004-03-04 17:01:23 EST
I get the same results :-) What happens if you run from the command line (i.e. 
not Eclipse)?
Comment 3 Brian Young CLA 2004-03-05 11:48:19 EST
When I run it at the command line it works (i.e. no eclipse).  I get the 
following output

About to schedule task.
Task begin
Task scheduled.
Please Enter 'e' + <Enter> to end task
text/html
Task begin
text/html
Task begin
text/html
e
Task ended !
Comment 4 Darin Wright CLA 2004-03-05 11:51:23 EST
So when you run in Eclipse, it hangs?
Comment 5 Brian Young CLA 2004-03-05 13:08:17 EST
Yes, when I run it in Eclipse and NOT under the debugger it appears to hang.  
Under the debugger it works as expected.
Comment 6 Jared Burns CLA 2004-03-05 18:16:39 EST
Luc, please test this on WinXP?
Comment 7 Brian Young CLA 2004-03-11 11:55:07 EST
Luc - have you been able to reproduce the problem?
Comment 8 Gordon Hamachi CLA 2004-04-07 17:50:06 EDT
I have seen a similar problem under 2.1.2 with my own code (not attached).  
The code runs correctly outside the debugger, but produces the wrong result in 
the debugger.  It runs the same both in and out of the debugger in JBuilder 8.
Comment 9 Gordon Hamachi CLA 2004-04-08 19:38:16 EDT
Followup on my previous comment
I have a case where the correct behavior (as defined by the command line 
execution of the JDK) is the same as the debugger, and normal execution within 
Eclipse is wrong.  Setting JVM argument -Xint clears up this problem, but of 
course your program runs slower.  Hope this clue helps.
Comment 10 Darin Wright CLA 2004-06-02 14:32:29 EDT
I'm getting the same (unexpected) behavior now on XP, using IBM 1.4.2 and 
JDK1.4.2. Using -Xint does not make a different on JDK1.4.2.
Comment 11 Darin Wright CLA 2004-06-11 16:15:58 EDT
Works for Kevin on XP/JDK1.4.2. Doesn't work for Darin on the same.
Comment 12 Darin Wright CLA 2004-06-11 16:57:14 EDT
We don't know why, but we found that the call to write to System.out is 
blocking in RUN mode, but not in DEBUG mode. If we put a 1 second wait before 
reading from System.in, the problem does not occurr.
Comment 13 Darin Wright CLA 2004-06-11 17:07:54 EDT
(I may have lied - it could be that #getContentType() is blocking).
Comment 14 Darin Wright CLA 2004-06-23 10:16:39 EDT
Nothing planned for 3.0
Comment 15 Steven Wasleski CLA 2005-01-21 15:41:47 EST
I can not recreate this problem on Eclipse 3.0.1 and IBM JRE 1.4.2 SR1 (SOV or 
J9).
Comment 16 Mike Wilson CLA 2006-02-02 12:52:47 EST
Darin, can you still cause this to happen?

Comment 17 Darin Wright CLA 2006-06-14 14:57:54 EDT
The problem still occurrs for me.
Comment 18 Mike Wilson CLA 2006-06-14 15:10:36 EDT
From the comment above, it seems like this is should be a problem with the specific combination of VM, base libraries and OS configuration. It's odd that it works when run from the command line though. Do we understand exactly what is failing yet? Can you replicate this with more recent VMs?

Also, is it possible to build a test case that exhibits the behavior but does not include running the app in Eclipse (e.g. does it fail if you fork the code to be run in a separate VM and pipe the output back to another one?). If we could find such a case, it would be worth reporting the problem to Sun.
Comment 19 Mike Wilson CLA 2006-12-18 10:53:40 EST
This bug has been marked LATER. Are people still seeing this issue? If so, can we please make another stab at fixing it?
Comment 20 Darin Wright CLA 2006-12-18 15:19:20 EST
I still see the problem in 3.3 M4. However, looking at this again, I believe this is a duplicat of bug 40066. There are two workarounds mentioned in the assocaited Sun bug (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4809647
).If I change the main method to the following, the program works as expected when running:

	public static void main(String args[]) {
		System.out.println("About to schedule task.");
		new MyTimer(3);
		System.out.println("Task scheduled.");
		System.out.println("Please Enter 'e' + <Enter> to end task");
		int c = 0;
		while (c != 101) {
			try {
				if (System.in.available() > 0) {
					c = System.in.read();
				}
			} catch (IOException e) {
				// e
				
				e.printStackTrace();
			}
		}
		System.out.println("Task ended !");
		System.exit(0);
	}
Comment 21 Darin Wright CLA 2006-12-18 15:19:46 EST

*** This bug has been marked as a duplicate of bug 40066 ***