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

Summary: Loop Halting in a C Project
Product: cnd Reporter: soldatov <soldatov>
Component: TerminalemulatorAssignee: ilia
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.2   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

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;
}