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 271490 - Loop Halting in a C Project
Summary: Loop Halting in a C Project
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Terminalemulator (show other bugs)
Version: 8.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: ilia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-16 19:15 UTC by soldatov
Modified: 2017-09-18 11:51 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 soldatov 2017-09-16 19:15:06 UTC
From Moshe Milshtein
=====================================
I am using NetBeans 8.2 in Ubuntu 17.04 with gcc 6.3.0.

I created a C project with the following code in main.c:

#include <stdio.h>

int main(void)
{
   double   x;

   for (x = 0.0; x <= 5.0; x += 0.1)
      printf("%f %f\n", x, x);
   
}

When running the project the loop is halting. Here is the end of the output that I see in the run window:
4.300000 4.300000
4.400000 4.400000
4.500000 4.500000
4.600000 4.600000
4.700000
RUN FINISHED; exit value 0; real time: 0ms; user: 0ms; system: 0ms

If I open a terminal window and build the same source with "gcc main.c" the program gives the expected result, looping until 5.0000000.
What's going on?
Thanks.
Comment 1 soldatov 2017-09-16 19:16:46 UTC
From me
===============================

Can you try 2 samples?
with delay
=================================================
#include <stdio.h>
#include <unistd.h>

int main()
{
   double   x;
   for (x = 0.0; x <= 5.0; x += 0.1) {
      printf("%f %f\n", x, x);
   }
   sleep(1);
   return 0;
}

force a write from buffer to stdout
=================================================
#include <stdio.h>

int main()
{
   double   x;
   for (x = 0.0; x <= 5.0; x += 0.1) {
      printf("%f %f\n", x, x);
   }
   fflush(stdout);
   return 0;
}
Comment 2 soldatov 2017-09-16 19:17:45 UTC
From Moshe Milshtein
=====================================

Flushing or closing stdout does not help.

My locale is en_US.UTF-8.

Adding a delay after the loop with sleep(1) (as suggested by soldatov) solves the problem.
Comment 3 soldatov 2017-09-16 19:29:38 UTC
Link to e-mail thread:
https://netbeans.org/projects/cnd/lists/users/archive/2017-09/message/17
Comment 4 soldatov 2017-09-16 19:44:09 UTC
Hm. I can reproduce this bug in NetBeans 8.2 patch 2, but original NetBeans 8.2 works nicely.
Comment 5 soldatov 2017-09-16 19:55:20 UTC
I see stable bug in NetBeans 8.2 patch 2 and NetBeans 8.2 original if I uses such code (50.0 instead of 5.0):

#include <stdio.h>

int main()
{
   double   x;
   for (x = 0.0; x <= 50.0; x += 0.1) {
      printf("%f %f\n", x, x);
   }
   return 0;
}