From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA10289; Thu, 4 Oct 2001 09:06:54 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA10279 for ; Thu, 4 Oct 2001 09:06:53 +0200 (MET DST) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f9476rP19209; Thu, 4 Oct 2001 09:06:53 +0200 (MET DST) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id JAA0000031904; Thu, 4 Oct 2001 09:06:52 +0200 (MET DST) From: Luc Maranget Message-Id: <200110040706.JAA0000031904@beaune.inria.fr> Subject: Re: [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ? To: jgm@cs.cornell.edu (Gregory Morrisett) Date: Thu, 4 Oct 2001 09:06:52 +0200 (MET DST) Cc: pierre.weis@inria.fr (Pierre Weis), danieljg@sundial.cs.cornell.edu (Daniel Grossman), caml-list@inria.fr In-Reply-To: <706871B20764CD449DB0E8E3D81C4D4301EE6C00@opus.cs.cornell.edu> from "Gregory Morrisett" at oct 04, 2001 12:29:47 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello > > The issue with threads is a bit more troublesome. Consider: > > let x : (int->int) option ref =3D ref (Some (fun x -> x));; > > let foo z =3D > match z with > {contents=3DNone} -> 0 > | {contents=3DSome(f)} -> f(0); > > Now suppose I fork two threads: > > Thread 1: foo x > Thread 2: x :=3D None > > And suppose that Thread 1 runs long enough that it does the first > match, so it assumes the contents of x is not of the form None. =20 > Now Thread 1 gets descheduled, Thread 2 runs, and sets the > contents of x to None. Then Thread 2 continues with the second > match... > > The question is, does Caml core dump because the pattern matcher > assumes that the contents *has* to be a Some(-) in the second > case? Or does it do the derefence and check atomically? Or > does it add a default case that raises a Match exception? =20 The compiled code is something like (if match/54 (apply (field 0 match/54) 0) 0) So the answer is: yes it coredumps. > > -Greg > ------------------- --Luc ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr