Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Strange behavior of the console
Strange behavior of the console [message #149578] Wed, 20 July 2005 07:20 Go to next message
Eclipse UserFriend
Originally posted by: jonkersbart.gmail.com

Hey,

I uses Eclipse 3.1 and build I200507180855 of CDT on a linux system in
combination with the GNU toolchain.
The program:

#include <stdio.h>
int add(int a, int b;
int main(int argc, char *argv[])
{
int int1, int2, res;
printf("Give the first integer: \n");
scanf("%d%*c", &int1);
printf("Give the second integer: \n");
scanf("%d%*c", &int2);
res = add(int1, int2);
printf("Result: %d\n",res);
return 0;
}

int add(int a, int b)
{
return a + b;
}

When I run the program, the first printf didn't appear at the console.
When I enter an integer I get the first and second printf at the screen.
After execution of the program the console looks like this:
4
Give the first integer:
Give the second integer:
7
Result: 11
When I debug the program or execute it at a prompt the program run as
expected and show the first printf.

Has somebody an idea to solve this problem?
Is this a bug?

Bart
Re: Strange behavior of the console [message #149620 is a reply to message #149578] Wed, 20 July 2005 11:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: j_apter.hotmail.com

Hmm, I was going to suggest that you might be seeing this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=102043
(Bug 102043 - Console Output Does Not Appear When Launching An
Application). However, your test case is a bit different than mine (I
also haven't tested the problem on linux yet).

Go to your workspace/.metadata directory and tell me if you see any
exceptions thrown in the .log file. I'd imagine that if you do see some
IOExceptions they may have a different error message since the "The handle
is invalid" message that appears in the mentioned bug is a Win32 API error
message.

Let me know if any of this seems to be related to your issue.

Bart Jonkers wrote:

> Hey,

> I uses Eclipse 3.1 and build I200507180855 of CDT on a linux system in
> combination with the GNU toolchain.
> The program:

> #include <stdio.h>
> int add(int a, int b;
> int main(int argc, char *argv[])
> {
> int int1, int2, res;
> printf("Give the first integer: n");
> scanf("%d%*c", &int1);
> printf("Give the second integer: n");
> scanf("%d%*c", &int2);
> res = add(int1, int2);
> printf("Result: %dn",res);
> return 0;
> }

> int add(int a, int b)
> {
> return a + b;
> }

> When I run the program, the first printf didn't appear at the console.
> When I enter an integer I get the first and second printf at the screen.
> After execution of the program the console looks like this:
> 4
> Give the first integer:
> Give the second integer:
> 7
> Result: 11
> When I debug the program or execute it at a prompt the program run as
> expected and show the first printf.

> Has somebody an idea to solve this problem?
> Is this a bug?

> Bart
Re: Strange behavior of the console [message #149629 is a reply to message #149620] Wed, 20 July 2005 11:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jonkersbart.gmail.com

DaCypher wrote:
> Hmm, I was going to suggest that you might be seeing this bug:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=102043
> (Bug 102043 - Console Output Does Not Appear When Launching An
> Application). However, your test case is a bit different than mine (I
> also haven't tested the problem on linux yet).
>
> Go to your workspace/.metadata directory and tell me if you see any
> exceptions thrown in the .log file. I'd imagine that if you do see some
> IOExceptions they may have a different error message since the "The
> handle is invalid" message that appears in the mentioned bug is a Win32
> API error message.
>
> Let me know if any of this seems to be related to your issue.

Yes there are some exceptions when I run the program:

!ENTRY org.eclipse.debug.core 4 120 2005-07-20 13:33:07.279
!MESSAGE Error logged from Debug Core:
!STACK 0
java.io.IOException: read error
at org.eclipse.cdt.utils.spawner.SpawnerInputStream.read0(Nativ e Method)
at
org.eclipse.cdt.utils.spawner.SpawnerInputStream.read(Spawne rInputStream.java:60)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at
org.eclipse.debug.internal.core.OutputStreamMonitor.read(Out putStreamMonitor.java:137)
at
org.eclipse.debug.internal.core.OutputStreamMonitor.access$1 (OutputStreamMonitor.java:127)
at
org.eclipse.debug.internal.core.OutputStreamMonitor$1.run(Ou tputStreamMonitor.java:193)
at java.lang.Thread.run(Unknown Source)

!ENTRY org.eclipse.debug.core 4 120 2005-07-20 13:33:07.280
!MESSAGE Error logged from Debug Core:
!STACK 0
java.io.IOException: close error
at
org.eclipse.cdt.utils.spawner.SpawnerOutputStream.close(Spaw nerOutputStream.java:68)
at
org.eclipse.debug.internal.core.InputStreamMonitor.write(Inp utStreamMonitor.java:109)
at
org.eclipse.debug.internal.core.InputStreamMonitor$1.run(Inp utStreamMonitor.java:80)
at java.lang.Thread.run(Unknown Source)


When I comment out the lines with the scanf function, the output appears
correctly.

Bart
>
> Bart Jonkers wrote:
>
>> Hey,
>
>
>> I uses Eclipse 3.1 and build I200507180855 of CDT on a linux system in
>> combination with the GNU toolchain.
>> The program:
>
>
>> #include <stdio.h>
>> int add(int a, int b;
>> int main(int argc, char *argv[])
>> {
>> int int1, int2, res;
>> printf("Give the first integer: n");
>> scanf("%d%*c", &int1);
>> printf("Give the second integer: n");
>> scanf("%d%*c", &int2);
>> res = add(int1, int2);
>> printf("Result: %dn",res);
>> return 0;
>> }
>
>
>> int add(int a, int b)
>> {
>> return a + b;
>> }
>
>
>> When I run the program, the first printf didn't appear at the console.
>> When I enter an integer I get the first and second printf at the
>> screen. After execution of the program the console looks like this:
>> 4
>> Give the first integer:
>> Give the second integer:
>> 7
>> Result: 11
>> When I debug the program or execute it at a prompt the program run as
>> expected and show the first printf.
>
>
>> Has somebody an idea to solve this problem?
>> Is this a bug?
>
>
>> Bart
>
>
Re: Strange behavior of the console [message #149669 is a reply to message #149629] Wed, 20 July 2005 23:15 Go to previous message
Eclipse UserFriend
Originally posted by: j_apter.hotmail.com

Yea, that seems to be the same bug. It appears as though the Eclipse guys
changed the way applications get launched. I believe a change was made in
the Eclipse 3.1RC2 release where they create a new thread to run the
launched application. This creates problems with the CDT launcher as
there is now a race condition between the actual running application and
CDT's console trying to capture the I/O (i.e. the application outputs the
printf before the other thread that captures the I/O can read from the
output descriptor). Most of this is just theory since I haven't had the
time to do a real debug on the problem, but I have a strong feeling that
simply synchronize'ing a method/block of code in a couple of places could
fix this. I mention this because the developers don't seem to be noticing
the issue so I'm trying to find someone with a bit more time than myself
to look into it (not to mention that few other people on this newsgroup
seem to notice it either). :)

In the meantime, I suggest going back to Eclipse 3.1RC1 which doesn't
exhibit this behavior. I am anxious to fix this bug so that I can use all
of the other latest plugins without having to run two copies of Eclipse.
:(

Bart Jonkers wrote:

> DaCypher wrote:
>> Hmm, I was going to suggest that you might be seeing this bug:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=102043
>> (Bug 102043 - Console Output Does Not Appear When Launching An
>> Application). However, your test case is a bit different than mine (I
>> also haven't tested the problem on linux yet).
>>
>> Go to your workspace/.metadata directory and tell me if you see any
>> exceptions thrown in the .log file. I'd imagine that if you do see some
>> IOExceptions they may have a different error message since the "The
>> handle is invalid" message that appears in the mentioned bug is a Win32
>> API error message.
>>
>> Let me know if any of this seems to be related to your issue.

> Yes there are some exceptions when I run the program:

> !ENTRY org.eclipse.debug.core 4 120 2005-07-20 13:33:07.279
> !MESSAGE Error logged from Debug Core:
> !STACK 0
> java.io.IOException: read error
> at org.eclipse.cdt.utils.spawner.SpawnerInputStream.read0(Nativ e Method)
> at
>
org.eclipse.cdt.utils.spawner.SpawnerInputStream.read(Spawne rInputStream.java:60)
> at java.io.BufferedInputStream.read1(Unknown Source)
> at java.io.BufferedInputStream.read(Unknown Source)
> at java.io.FilterInputStream.read(Unknown Source)
> at
>
org.eclipse.debug.internal.core.OutputStreamMonitor.read(Out putStreamMonitor.java:137)
> at
>
org.eclipse.debug.internal.core.OutputStreamMonitor.access$1 (OutputStreamMonitor.java:127)
> at
>
org.eclipse.debug.internal.core.OutputStreamMonitor$1.run(Ou tputStreamMonitor.java:193)
> at java.lang.Thread.run(Unknown Source)

> !ENTRY org.eclipse.debug.core 4 120 2005-07-20 13:33:07.280
> !MESSAGE Error logged from Debug Core:
> !STACK 0
> java.io.IOException: close error
> at
>
org.eclipse.cdt.utils.spawner.SpawnerOutputStream.close(Spaw nerOutputStream.java:68)
> at
>
org.eclipse.debug.internal.core.InputStreamMonitor.write(Inp utStreamMonitor.java:109)
> at
>
org.eclipse.debug.internal.core.InputStreamMonitor$1.run(Inp utStreamMonitor.java:80)
> at java.lang.Thread.run(Unknown Source)


> When I comment out the lines with the scanf function, the output appears
> correctly.

> Bart
>>
>> Bart Jonkers wrote:
>>
>>> Hey,
>>
>>
>>> I uses Eclipse 3.1 and build I200507180855 of CDT on a linux system in
>>> combination with the GNU toolchain.
>>> The program:
>>
>>
>>> #include <stdio.h>
>>> int add(int a, int b;
>>> int main(int argc, char *argv[])
>>> {
>>> int int1, int2, res;
>>> printf("Give the first integer: n");
>>> scanf("%d%*c", &int1);
>>> printf("Give the second integer: n");
>>> scanf("%d%*c", &int2);
>>> res = add(int1, int2);
>>> printf("Result: %dn",res);
>>> return 0;
>>> }
>>
>>
>>> int add(int a, int b)
>>> {
>>> return a + b;
>>> }
>>
>>
>>> When I run the program, the first printf didn't appear at the console.
>>> When I enter an integer I get the first and second printf at the
>>> screen. After execution of the program the console looks like this:
>>> 4
>>> Give the first integer:
>>> Give the second integer:
>>> 7
>>> Result: 11
>>> When I debug the program or execute it at a prompt the program run as
>>> expected and show the first printf.
>>
>>
>>> Has somebody an idea to solve this problem?
>>> Is this a bug?
>>
>>
>>> Bart
>>
>>
Previous Topic:standard make c project : no rule to make target all
Next Topic:Exclude files from managed make
Goto Forum:
  


Current Time: Sat Jul 27 16:21:14 GMT 2024

Powered by FUDForum. Page generated in 0.03396 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top