compiler-explorer: [BUG]: stdout not collected from a crashing execution

Describe the bug

Reported in a linkedin discussion: When executing this in CE -

#include <iostream>

int main() {
    std::cerr << "aaa\n";
    std::cout << "bbbb\n"; 

    int* ptr = nullptr;
    int x = *ptr;
}

Shows just aaa. This seems to be due to buffering, as if we add to the cout line -

    std::cout << "bbbb\n" << std::flush;

‘bbbb’ is shown as well.

Hopefully something can be done about it in node…

Steps to reproduce

Expected behavior

Reproduction link

https://compiler-explorer.com/z/of49MKWz5

Screenshots

Not applicable

Operating System

No response

Browser version

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 31 (30 by maintainers)

Commits related to this issue

Most upvoted comments

I still prefer us setting up a fake tty. Just needs a bit of a tweak in our sandbox, and a build of the fake tty binary.

I forget what went wrong with stdbuf that caused us to revert that fix - but it was reverted and I’m reopening the issue.

https://github.com/compiler-explorer/compiler-explorer/pull/7482/files https://github.com/compiler-explorer/compiler-explorer/issues/7427

Truth be told, I don’t think we should do anything about this. Hiding normal behavior is not something anyone learns from.

When building and running on a terminal - buffered IO does show for crashing apps. This is perceived as ‘normal’ behavior, and if we could replicate that I think we should.