[Lldb-commits] [lldb] r148201 - in /lldb/trunk/source/Core: ConnectionFileDescriptor.cpp Debugger.cpp
Greg Clayton
gclayton at apple.com
Sat Jan 14 12:47:38 PST 2012
Author: gclayton
Date: Sat Jan 14 14:47:38 2012
New Revision: 148201
URL: http://llvm.org/viewvc/llvm-project?rev=148201&view=rev
Log:
<rdar://problem/9731573>
Fixed two double "int close(int fd)" issues found by our file descriptor
interposing library on darwin:
The first is in SBDebugger::SetInputFileHandle (FILE *file, bool transfer_ownership)
where we would give our FILE * to a lldb_private::File object member variable and tell
it that it owned the file descriptor if "transfer_ownership" was true, and then we
would also give it to the communication plug-in that waits for stdin to come in and
tell it that it owned the FILE *. They would both try and close the file.
The seconds was when we use a file descriptor through ConnectionFileDescriptor
where someone else is creating a connection with ConnectionFileDescriptor and a URL
like: "fd://123". We were always taking ownwership of the fd 123, when we shouldn't
be. There is a TODO in the comments that says we should allow URL options to be passed
to be able to specify this later (something like: "fd://123?transer_ownership=1"), but
we can get to this later.
Modified:
lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
lldb/trunk/source/Core/Debugger.cpp
Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=148201&r1=148200&r2=148201&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Sat Jan 14 14:47:38 2012
@@ -174,7 +174,16 @@
bool is_socket = GetSocketOption (m_fd_send, SOL_SOCKET, SO_REUSEADDR, resuse) == 0;
if (is_socket)
m_fd_send_type = m_fd_recv_type = eFDTypeSocket;
- m_should_close_fd = true;
+ // Don't take ownership of a file descriptor that gets passed
+ // to us since someone else opened the file descriptor and
+ // handed it to us.
+ // TODO: Since are using a URL to open connection we should
+ // eventually parse options using the web standard where we
+ // have "fd://123?opt1=value;opt2=value" and we can have an
+ // option be "owns=1" or "owns=0" or something like this to
+ // allow us to specify this. For now, we assume we must
+ // assume we don't own it.
+ m_should_close_fd = false;
return eConnectionStatusSuccess;
}
}
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=148201&r1=148200&r2=148201&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Sat Jan 14 14:47:38 2012
@@ -410,7 +410,10 @@
// Disconnect from any old connection if we had one
m_input_comm.Disconnect ();
- m_input_comm.SetConnection (new ConnectionFileDescriptor (in_file.GetDescriptor(), true));
+ // Pass false as the second argument to ConnectionFileDescriptor below because
+ // our "in_file" above will already take ownership if requested and we don't
+ // want to objects trying to own and close a file descriptor.
+ m_input_comm.SetConnection (new ConnectionFileDescriptor (in_file.GetDescriptor(), false));
m_input_comm.SetReadThreadBytesReceivedCallback (Debugger::DispatchInputCallback, this);
Error error;
More information about the lldb-commits
mailing list