[ 
https://issues.apache.org/jira/browse/THRIFT-900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12911159#action_12911159
 ] 

Christian Lavoie edited comment on THRIFT-900 at 9/26/10 12:57 PM:
-------------------------------------------------------------------

Compiles but crashes on startup (in the ::listen call) on Mac OS X 10.6:

Darwin -- 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; 
root:xnu-1504.7.4~1/RELEASE_I386 i386
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

{noformat}
$ ./testServer
Starting the server...
testServer(67587) malloc: *** error for object 0x7fff5fbff070: pointer being 
freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap
{noformat}

Looking at the patch, the following looks bogus:

{noformat} 
+  if(! path_.empty()){
+    struct sockaddr_un address;
+
+    if (path_.length() > sizeof(address.sun_path)) {
+      int errno_copy = errno;
+      GlobalOutput.perror("TSocket::open() Unix Domain socket path too long", 
errno_copy);
+      throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain 
socket path too long");
+    }
+
+    address.sun_family = AF_UNIX;
+    res->ai_addrlen = sizeof(address.sun_family) + sprintf(address.sun_path, 
path_.c_str());
+    res->ai_addr = (struct sockaddr *) &address;
+  }
{noformat}

once the if block finishes, address goes out of scope and res->ai_addr becomes 
a dangling pointer, which freeaddrinfo barfs on in TServerSocket.cpp.

      was (Author: clavoie):
    Compiles but crashes on startup (in the ::listen call) on Mac OS X 10.6:

Darwin -- 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; 
root:xnu-1504.7.4~1/RELEASE_I386 i386
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

$ ./testServer
Starting the server...
testServer(67587) malloc: *** error for object 0x7fff5fbff070: pointer being 
freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap

Looking at the patch, the following looks bogus:
 
+  if(! path_.empty()){
+    struct sockaddr_un address;
+
+    if (path_.length() > sizeof(address.sun_path)) {
+      int errno_copy = errno;
+      GlobalOutput.perror("TSocket::open() Unix Domain socket path too long", 
errno_copy);
+      throw TTransportException(TTransportException::NOT_OPEN, " Unix Domain 
socket path too long");
+    }
+
+    address.sun_family = AF_UNIX;
+    res->ai_addrlen = sizeof(address.sun_family) + sprintf(address.sun_path, 
path_.c_str());
+    res->ai_addr = (struct sockaddr *) &address;
+  }

once the if block finishes, address goes out of scope and res->ai_addr becomes 
a dangling pointer, which freeaddrinfo barfs on in TServerSocket.cpp.
  
> Unix domain socket
> ------------------
>
>                 Key: THRIFT-900
>                 URL: https://issues.apache.org/jira/browse/THRIFT-900
>             Project: Thrift
>          Issue Type: New Feature
>          Components: C++ - Library
>         Environment: Debian GNU/Linux Lenny
>            Reporter: Roger Meier
>             Fix For: 0.5
>
>         Attachments: THRIFT-900_UnixDomainSockets.v2.patch, 
> THRIFT-900_UnixDomainSockets.v3.patch, THRIFT-900_UnixDominSockets.patch
>
>
> I would like to use Unix domain sockets.
> client side:
> {code}
> shared_ptr<TSocket> socket(new TSocket("/tmp/ThriftTest.binary.thrift"));
> // as alternative to
> shared_ptr<TSocket> socket(new TSocket(host, port));
> {code}
> server side:
> {code}
> shared_ptr<TServerSocket> serverSocket(new 
> TServerSocket("/tmp/ThriftTest.binary.thrift"));
> // as alternative to
> shared_ptr<TServerSocket> serverSocket(new TServerSocket(port));
> {code}
> further enhancement might be:
> use a RFC 3986 compliant URI parser e.g. by using 
> http://uriparser.sourceforge.net/ (BSD License)
> and pass a real URI to the constructor, e.g. 
> file:///tmp/ThriftTest.binary.thrift

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to