From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id C95D6BC0A for ; Sat, 5 May 2007 16:13:50 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l45EDoSN031537 for ; Sat, 5 May 2007 16:13:50 +0200 Received: by ug-out-1314.google.com with SMTP id k3so715689ugf for ; Sat, 05 May 2007 07:13:50 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=eOS0k5yLq2I9LWdzmH4X8Bhy7zwMCCs+BfRyjT3L2TvAh1QBtQRf/pvDUmVqnpscO1cYcstDPf+QqClhHvRQV0nSZ3r1wm8bD8mPtPZhfDBvDH7jDFaQop8jWuwdw0cSulPMMSg8x8Y1EHu6Ha21zI4RRAitZTuLqEokA+aB9OQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=uCp8vaJb/snvPlE0SAi8l8qwj4TLkXXJFFuS+tL8GqNOed2wI3fWUMav6L1hDGRT1+nWwBFWXPbU08CYbfMbM1FRbefSvQiYCn7KArbdjreiI3qdWFS4Y92fsuDFVXTdh4f8wyAlvQ5/2NY0x7UcBe+Ioaxt85vQpLzns7HvRho= Received: by 10.82.180.17 with SMTP id c17mr8335780buf.1178374429945; Sat, 05 May 2007 07:13:49 -0700 (PDT) Received: from ?192.168.1.33? ( [83.34.3.221]) by mx.google.com with ESMTP id y37sm4034381iky.2007.05.05.07.13.48; Sat, 05 May 2007 07:13:48 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: References: <71B2C4B5-3ECB-450F-B015-3C5EAB90855F@gmail.com> <75F71DDF-CACC-4AD9-A3DA-E0049FC9FB2F@gmail.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <307C6D82-55E3-42AD-B0B1-8C1DFC22394A@gmail.com> Content-Transfer-Encoding: 7bit From: Joel Reymont Subject: Serious bug in the OCaml FFI? Date: Sat, 5 May 2007 15:13:44 +0100 To: OCaml List X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 463C911E.000 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 463C911E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bug:01 ocaml:01 ffi:01 osx:01 ocaml:01 topfind:01 getpeername:01 toplevel:01 otherlibs:01 elif:01 undef:01 undef:01 otherlibs:01 camlprim:01 printf:01 I'm using 32-bit Mac OSX 10.4.9 Intel. I inserted a print-out into my version of socketpair.c [1] and ran my OCaml test script #use "topfind";; #require "unix";; let x, y = Unix.socketpair Unix.PF_UNIX Unix.SOCK_STREAM 0;; Unix.getpeername y;; which resulted in unix_socketpair: domain = 1, type = 1, proto = 0 Exception: Unix.Unix_error (Unix.EAFNOSUPPORT, "", ""). Back at the toplevel # (Obj.magic Unix.PF_UNIX:int);; - : int = 0 # (Obj.magic Unix.SOCK_STREAM:int);; - : int = 0 Now, how exactly does 0 become 1 here? I have no idea but there are two tables defined in otherlibs/unix/socket.c: int socket_domain_table[] = { PF_UNIX, PF_INET, #if defined(HAS_IPV6) PF_INET6 #elif defined(PF_UNDEF) PF_UNDEF #else 0 #endif }; int socket_type_table[] = { SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET }; As you can see, instead of calling socketpair with PF_UNIX and SOCK_STREAM), Ocaml is calling it with PF_INET6 and SOCK_DGRAM instead. This is obviously a major problem. Any suggestions on what may be causing it and how to fix it? Thanks, Joel [1] otherlibs/unix/socketpair.c CAMLprim value unix_socketpair(value domain, value type, value proto) { int sv[2]; value res; printf("unix_socketpair: domain = %d, type = %d, proto = %d\n", socket_domain_table[Int_val(domain)], socket_type_table[Int_val(type)], Int_val(proto)); if (socketpair(socket_domain_table[Int_val(domain)], socket_type_table[Int_val(type)], Int_val(proto), sv) == -1) uerror("socketpair", Nothing); res = alloc_small(2, 0); Field(res,0) = Val_int(sv[0]); Field(res,1) = Val_int(sv[1]); return res; } -- http://wagerlabs.com/