The apr_file_dup2() function in apr/file_io/win32/filedup.c calls _commit() for standard file handles 0, 1 and 2.
The _commit() function will assert with the message "Invalid file descriptor. File possibly closed by a different thread" or return a value of -1 if the file handle refers to a device.
The assert will appear if APR is compiled in debug mode.
This can be seen by running "testall.exe testdup".
But if file redirection is used (such as "testall.exe testdup > outfile 2>&1"), then the test completes successfully.
I have attached a patch that corrects this problem by checking _isatty().
Credit goes to Jeff Trawick for catching this problem in the first place.