caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Luc Maranget <luc.maranget@inria.fr>
To: jgm@cs.cornell.edu (Gregory Morrisett)
Cc: pierre.weis@inria.fr (Pierre Weis),
	danieljg@sundial.cs.cornell.edu (Daniel Grossman),
	caml-list@inria.fr
Subject: Re: [Caml-list] Pattern matcher no more supposed to warn on non  exhaustive patterns ?
Date: Thu, 4 Oct 2001 09:06:52 +0200 (MET DST)	[thread overview]
Message-ID: <200110040706.JAA0000031904@beaune.inria.fr> (raw)
In-Reply-To: <706871B20764CD449DB0E8E3D81C4D4301EE6C00@opus.cs.cornell.edu> from "Gregory Morrisett" at oct 04, 2001 12:29:47

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


  reply	other threads:[~2001-10-04  7:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-04  4:29 Gregory Morrisett
2001-10-04  7:06 ` Luc Maranget [this message]
2001-10-04  8:17 ` Jacques Garrigue
2001-10-04 12:28 ` Xavier Leroy
  -- strict thread matches above, loose matches on Subject: below --
2001-10-04  7:36 Damien Doligez
2001-10-04  7:51 ` Einar Karttunen
2001-10-03 17:37 Jean-Marc Eber
2001-10-03 16:54 ` Dan Grossman
2001-10-03 20:52   ` Pierre Weis
2001-10-04  7:55 ` Luc Maranget
2001-10-04  9:06   ` Luc Maranget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200110040706.JAA0000031904@beaune.inria.fr \
    --to=luc.maranget@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=danieljg@sundial.cs.cornell.edu \
    --cc=jgm@cs.cornell.edu \
    --cc=pierre.weis@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).