[PATCH] D13128: Fix backend crash on multiple close of stdout.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 22:17:10 PDT 2015
ABataev updated the summary for this revision.
ABataev updated this revision to Diff 35698.
ABataev added a comment.
Reworked patch after some discussion
http://reviews.llvm.org/D13128
Files:
lib/Support/raw_ostream.cpp
test/Other/empty.ll
Index: lib/Support/raw_ostream.cpp
===================================================================
--- lib/Support/raw_ostream.cpp
+++ lib/Support/raw_ostream.cpp
@@ -490,8 +490,8 @@
static int getFD(StringRef Filename, std::error_code &EC,
sys::fs::OpenFlags Flags) {
// Handle "-" as stdout. Note that when we do this, we consider ourself
- // the owner of stdout. This means that we can do things like close the
- // file descriptor when we're done and set the "binary" flag globally.
+ // the owner of stdout. This means that we can do things like set the "binary"
+ // flag globally.
if (Filename == "-") {
EC = std::error_code();
// If user requested binary then put stdout into binary mode if
@@ -523,6 +523,10 @@
return;
}
+ // Do not close standard input/output streams.
+ if (FD <= STDERR_FILENO)
+ ShouldClose = false;
+
// Get the starting position.
off_t loc = ::lseek(FD, 0, SEEK_CUR);
#ifdef LLVM_ON_WIN32
Index: test/Other/empty.ll
===================================================================
--- test/Other/empty.ll
+++ test/Other/empty.ll
@@ -0,0 +1,2 @@
+; RUN: /export/bpart/_users/abataev/development/llvm_commit3/build/bin/opt -analyze -time-passes -rewrite-map-file=- -stats -info-output-file=- %s 2>&1 | FileCheck %s
+; CHECK: Total Execution Time
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13128.35698.patch
Type: text/x-patch
Size: 1344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150925/4a0d09a7/attachment.bin>
More information about the cfe-commits
mailing list