← Back to team overview

touch-packages team mailing list archive

[Bug 1381792] [NEW] Merged stdout and stderr redirected to a file causes wrong ordering

 

Public bug reported:

I'm using Ubuntu 14.10 dev with bash 4.3-11ubuntu1 and if stdout is
redirected to a file and stderr is redirected to stdout the order isn't
correct anymore. I have written a testcase to demonstrate the problem:

#include <stdio.h>

int main()
{
 short unsigned i;

 for(i = 0; i < 1024; ++i)
 {
  fprintf(stdout, "stdout\n");
  fprintf(stderr, "stderr\n");
 }
 return 0;
}

The code needs to be compiled with gcc for example as "gcc -Wall
-pedantic -o test test.c". On executing "./test > test.log 2>&1" I would
normally expect that the lines "stdout" and "stderr" are alternating
with each other but I'm seeing a few hundred lines "stderr" and then a
few hundred lines "stdout" and so on. Interestingly on every try I'm
also seeing on line 1171 "sstderr" and on line 1610 "tdout" (these both
lines seems to got mixed up).

** Affects: bash (Ubuntu)
     Importance: Undecided
         Status: New

** Description changed:

  I'm using Ubuntu 14.10 dev with bash 4.3-11ubuntu1 and if stdout is
  redirected to a file and stderr is redirected to stdout the order isn't
  correct anymore. I have written a testcase to demonstrate the problem:
  
  #include <stdio.h>
  
  int main()
  {
- 	short unsigned i;
+  short unsigned i;
  
- 	for(i = 0; i < 1024; ++i)
- 	{
- 		fprintf(stdout, "stdout\n");
- 		fprintf(stderr, "stderr\n");
- 	}
- 	return 0;
+  for(i = 0; i < 1024; ++i)
+  {
+   fprintf(stdout, "stdout\n");
+   fprintf(stderr, "stderr\n");
+  }
+  return 0;
  }
  
- 
- The code needs to be compiled with gcc for example as "gcc -Wall -pedantic -o test test.c". On executing "./test > test.log 2>&1" I would normally expect that the lines "stdout" and "stderr" are alternating with each other but I'm seeing a few hundred lines "stderr" and the a few hundred lines "stdout" and so on. Interestingly on every try I'm also seeing on line 1171 "sstderr" and on line 1610 "tdout" (these both lines seems to got mixed up).
+ The code needs to be compiled with gcc for example as "gcc -Wall
+ -pedantic -o test test.c". On executing "./test > test.log 2>&1" I would
+ normally expect that the lines "stdout" and "stderr" are alternating
+ with each other but I'm seeing a few hundred lines "stderr" and then a
+ few hundred lines "stdout" and so on. Interestingly on every try I'm
+ also seeing on line 1171 "sstderr" and on line 1610 "tdout" (these both
+ lines seems to got mixed up).

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1381792

Title:
  Merged stdout and stderr redirected to a file causes wrong ordering

Status in “bash” package in Ubuntu:
  New

Bug description:
  I'm using Ubuntu 14.10 dev with bash 4.3-11ubuntu1 and if stdout is
  redirected to a file and stderr is redirected to stdout the order
  isn't correct anymore. I have written a testcase to demonstrate the
  problem:

  #include <stdio.h>

  int main()
  {
   short unsigned i;

   for(i = 0; i < 1024; ++i)
   {
    fprintf(stdout, "stdout\n");
    fprintf(stderr, "stderr\n");
   }
   return 0;
  }

  The code needs to be compiled with gcc for example as "gcc -Wall
  -pedantic -o test test.c". On executing "./test > test.log 2>&1" I
  would normally expect that the lines "stdout" and "stderr" are
  alternating with each other but I'm seeing a few hundred lines
  "stderr" and then a few hundred lines "stdout" and so on.
  Interestingly on every try I'm also seeing on line 1171 "sstderr" and
  on line 1610 "tdout" (these both lines seems to got mixed up).

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1381792/+subscriptions


Follow ups

References