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 222237 - Output truncated during debug session in C++
Summary: Output truncated during debug session in C++
Status: RESOLVED INCOMPLETE
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 7.2.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: henk89
URL:
Keywords: USABILITY
Depends on:
Blocks:
 
Reported: 2012-11-15 21:35 UTC by aschwarz1309
Modified: 2013-05-24 11:18 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
An example test case showing the issue (7.98 KB, text/plain)
2012-12-16 22:23 UTC, aschwarz1309
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aschwarz1309 2012-11-15 21:35:43 UTC
Product Version = NetBeans IDE 7.2.1 (Build 201210100934)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.7.0_03
Runtime = Java HotSpot(TM) Client VM 22.1-b02
gcc (GCC) 4.5.3
GNU gdb (GDB) 7.5.50.20120815-cvs (cygwin-special)

If the last output(s) before application exit is not preceeded with a delay then the output(s) is truncated. This occurred when I was using GDB 4.5.3 as well as the current version.

Putting "cout << flush" has not effect. I put a 'sleep(1)' to suspend application execution for 1s prior to exit, and this seems to clear the issue. In my case, considerable output is truncated (several hundred lines).

Since there is a workaround, viz., "sleep(1)", the issue is not critical.
Comment 1 henk89 2012-11-26 11:42:17 UTC
Could you give me more information about how to reproduce the issue?
Comment 2 aschwarz1309 2012-11-26 13:33:35 UTC
Well I have a large amount of output(cout << data) in a single-threaded application. After return from the output function, I exit. If I exit prior to completion of the output, the output is truncated unless a sleep(1) is inserted.  This happens during a debug session. 

I haven't looked at the Netbeans or other code but I think(?) that what is happening is that the output is deferred to an output thread, allowing output to proceed independently from execution. At termination from the main thread the runtime kernel (or Netbeans) does not check to see if the output thread is still active, viz., is processing a job. Instead, when the main thread terminates the debugger (Netbeans?) causes the output thread to terminate. Putting in a delay allows the output thread to complete before an automatic thread termination is executed. But, this is just a guess.

If my guess is correct then the problem can be duplicated by having a C++ function output (about) 20,000 characters and then exit immediately on return while in a debug session. If the 'bug' occurs then the output should be truncated.

Thanks for looking into this;
art
Comment 3 henk89 2012-11-27 09:12:54 UTC
I'm still not able to reproduce the problem. Could you try using GDB from a terminal? As we stop GDB using a special GDB/MI command and GDB manages all the debugging process by itself, there seems to be no problem with a GDB termination.
Comment 4 aschwarz1309 2012-11-28 23:58:34 UTC
I'll try to generate a test case. Sorry about the delay, I was given a good case of bronchitis and forced to celebrate Thanksgiving (in the US). I'll try to be more diligent in my responses.

art
Comment 5 aschwarz1309 2012-12-16 22:23:34 UTC
Created attachment 129428 [details]
An example test case showing the issue

cygwin gcc 4.5.3
       gdb 7.5.50.20120815-cvs (cygwin-special)

The attachment has a test case. When the code is executed in the debugger without a breakpoint, the last 4 functions calls are not output and the first func2() generates a header line and some text. When the 'sleep(1)' statement is uncommented all lines are output.

Forgive the code. This is a test case.
Comment 6 henk89 2013-04-25 07:02:23 UTC
Please, attach the gdb log from the session.
http://wiki.netbeans.org/GdbLog
Comment 7 henk89 2013-04-29 08:01:48 UTC
I tried the both scenarios. The output was absolutely the same.
Comment 8 couozu 2013-05-24 11:18:06 UTC
http://stackoverflow.com/questions/16733148/it-seems-that-stdflush-doesnt-work-with-stdcout

Reproduces also on Linux environment.