Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output for CLion IDE sometimes cuts off when executing a program

Tags:

clion

When using CLion I have found the output sometimes cuts off.

For example when running the code:

main.cpp

#include <stdio.h>

int main() {

    int i;
    for (i = 0; i < 1000; i++) {
        printf("%d\n", i);
    }
    fflush(stdout); // Shouldn't be needed as each line ends with "\n"

    return 0;
}

Expected Output

The expected output is obviously the numbers 0-999 on each on a new line

Actual Output

After executing the code multiple times within CLion, the output often changes:

  • Sometimes it executes perfectly and shows all the numbers 0-999
  • Sometimes it cuts off at different points (e.g. 0-840)
  • Sometimes it doesn't output anything

The return code is always 0!

Screenshot

terminal output cuts off

Running the code in a terminal (i.e. not in CLion itself)

However, the code outputs the numbers 0-999 perfectly when compiling and running the code using the terminal.

I have spent so much time on this thinking it was a problem with my code and a memory issue until I finally realised that this was just an issue with CLion.

OS: Ubuntu 14.04 LTS

Version: 2016.1

Build: #CL-145.258

Update

A suitable workaround is to run the code in debug mode (thanks to @olaf).

like image 280
Yahya Uddin Avatar asked Mar 28 '16 19:03

Yahya Uddin


1 Answers

The consensus is that this is an IDE issue. Therefore, I have reported the bug.

A suitable workaround is to execute the code in debug mode (no breakpoint required).

I will update this question, as soon as this bug is fixed.

Update 1

WARNING: You should not change information in registry unless you have been asked specifically by JetBrains. Registry is not in the main menu for a reason! Use the following solution at your own risk!!!

JetBrains have contacted me and provided a suitable solution:

  1. Go to the Find Action Dialog box (CTRL+SHIFT+A)
  2. Search for "Registry..."
  3. Untick run.processes.with.pty

Should then work fine!

Update 2

The bug has been added here: https://youtrack.jetbrains.com/issue/CPP-6254

Feel free to upvote it!

like image 81
Yahya Uddin Avatar answered Sep 22 '22 15:09

Yahya Uddin