From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 2770CBBBB for ; Thu, 2 Mar 2006 00:07:45 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k21N7imL002116 for ; Thu, 2 Mar 2006 00:07:44 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA07887 for ; Thu, 2 Mar 2006 00:07:44 +0100 (MET) Received: from sMtp.neuf.fr (sp604002mt.neufgp.fr [84.96.92.61]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k21N7hoi011978 for ; Thu, 2 Mar 2006 00:07:43 +0100 Received: from bolet.myco.ath.cx ([84.4.27.30]) by sp604002mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-4.03 (built Sep 22 2005)) with ESMTP id <0IVH002HO1KVXB90@sp604002mt.gpm.neuf.ld> for caml-list@inria.fr; Thu, 02 Mar 2006 00:07:43 +0100 (CET) Received: from localhost ([127.0.0.1] helo=bolet ident=www-data) by bolet.myco.ath.cx with smtp (Exim 4.50) id 1FEaPu-0007pV-Gf for caml-list@inria.fr; Thu, 02 Mar 2006 00:07:34 +0100 Date: Thu, 02 Mar 2006 00:07:34 +0100 From: Louis Gesbert Subject: Re: [Caml-list] Bugs with pattern-matching and exceptions To: caml-list@inria.fr Reply-To: louis.gesbert@laposte.net Message-id: MIME-version: 1.0 X-Mailer: Hastymail 1.4 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Priority: 3 X-j-chkmail-Score: MSGID : 4406293F.000 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44062940.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4406293F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 marshalling:01 type-safe:01 marshalling:01 bug:01 exn:01 pointer:01 pointer:01 bytecode:01 pointers:01 equality:01 marshal:01 marshal:01 exception:01 exception:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 > Marshalling is known to be type unsafe, of course, so that's "not a > problem" although it would be nice to have type-safe marshalling. I don't agree here, there really *is* a problem with marshalling exceptions, independently from type safety: it doesn't work. This problem has already been mentionned on the list (and in the bug tracker), which is why I didn't describe it in detail. However, it would be nice to have a word from the caml team about it. Let's suppose we have two processes running the exact same compiled program. - Process A marshalls an exception (Ex "arg") - Process A transmits the resulting string to process B - Process B unmarshalls the string, and makes sure to type it as an exception. Since we have the same compiled program, exception Ex is defined in the same way in A and B. - On process B, the exception *seems* right, and you can test equality. However, if you try to pattern-match against it, the process just hangs. As I understand it, the constructor Ex of the variant type exn is represented by a pointer in (Ex "arg"), and this pointer is kept as-is by the marshaller which doesn't understand the particular structure of exceptions. The (awfully ugly ;-)) workaround I used (I *really* needed to marshal exceptions, you see...) is to extract the constructor (as a string) and the parameters from the exception, using Obj, marshal the couple and deal with it on the receiving hand. > However, what happens with dynamically loaded bytecode that declares > new exceptions? Perhaps there is some unsoundness there... :-) Yes, that could be worth looking into, but I don't actually think it makes the problem worse since the structure of exceptions is already dynamic. Thanks for the pointers :-) Louis