caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Carr <jfc@mit.edu>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Strange crash after switching to first class modules
Date: Thu, 29 Sep 2011 13:03:34 -0400	[thread overview]
Message-ID: <201109291703.p8TH3YXM021785@outgoing.mit.edu> (raw)
In-Reply-To: <4E849E44.3050002@inria.fr>


Xavier Leroy <Xavier.Leroy@inria.fr> wrote:

> Could you first try to eliminate that partial application of fprintf?
> (Inline f at point of call, or eta-expand yourself.)  The Printf
> module takes a lot of liberties with the type system (ahem), so it is
> one of the usual suspects in such a case.

The program still crashes if I eta expand.  But it has a different
stack trace due to different tail calls and I think I understand
the problem:

Unpacking a module to provide a functor argument does not permute fields
to match the required signature.

I have a module that I use to represent another module plus another bit
of information paired with the base type of the other module.

	module M : C with type t = t1 * t2 = struct
	  type t = t1 * t2
	  let format chan (a,b) = ... (* format first part then second part *)
	  and f1 (a1,b1) (a2,b2) = ...
	  and f2 (a1,b1) (a2,b2) = ...
	  and equal (a1,b1) (a2,b2) = ...
	  and hash (a1,b2) = ...
	end

This module, packed into a value and unpacked, is the argument to the
Hashtbl.Make functor.

The stack trace goes from

  Hashtbl.MakeSeeded.mem -> M.format -> another format function -> crash

Hashtbl.mem doesn't call the format method because there is no format
type in the functor argument.  It calls equal.  It reads the first
value in the module expecting an equal method and finding something
else.

I think the module value is not being reformatted to the type expected
by Hashtbl.Make.

Is this enough of a clue or do you want me to try cutting it down to
a smaller example?


      reply	other threads:[~2011-09-29 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29 16:03 John Carr
2011-09-29 16:35 ` Xavier Leroy
2011-09-29 17:03   ` John Carr [this message]

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=201109291703.p8TH3YXM021785@outgoing.mit.edu \
    --to=jfc@mit.edu \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@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).