caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@maxtal.com.au>
To: David Mentre <David.Mentre@inria.fr>, caml-list@inria.fr
Subject: Re: [Caml-list] Segfault in a native code program using pm variants
Date: Wed, 22 Aug 2001 05:20:51 +1000	[thread overview]
Message-ID: <3B82B493.BD6DCA52@maxtal.com.au> (raw)
In-Reply-To: <qtl3d6m4vkt.fsf@pochi.inria.fr>

I hope it's not catching. Just after reproducing
David Mentre's segfault, now I'm getting one in my code too ;-)

Data: Ocaml 3.02, Linux on PIII 550E, i86 native code compiler, compiled
with pthreads
enabled. I am using the bignum module, but no threads, no magic, no
marshal,
no special integer types, no floats, and no non-standard modules. 
The application is the Felix compiler.
Parsing and desugaring passes have run (correctly, as far as I can tell)

Noramlly, I'd suspect an infinite recursion, 
(the code is very recursive, and I actually _expected_ it)
but it happens very quickly without disk thrashing (I'm running as
root),
and all attempts to trace the recursion using prints
have failed (so far). I've just got this code to compile
after a significant rewrite in which I also switched
almost all variant usage to polymorphic variants.

What I am seeing, however, is an incorrect match using polymorphic
variants: here's the debugging output:

typeofindex finds declaration proc print: int = "printf(\"%d\",$1);";
Found var
:--->declaration proc print: int = "printf(\"%d\",$1);";

That 'found var' comes from 

and typeofindex 
  (dfns:symbol_table_t) 
  (counter:int ref)
  (freg:instantiation_registry_t)
  (exclude:int list)
  (excluded_dirs:int list)
  (index:int)
: btypecode_t = 
...
  let bt t:btypecode_t = 
    print_endline ("TYPEOFINDEX binding type " ^ string_of_typecode t);
    flush stdout;
    let t' = bind_type dfns counter freg env (index::exclude)
excluded_dirs sr t in
    print_endline "TYPE BOUND";
    t'
  in
... 
    print_endline ("typeofindex finds " ^ string_of_symdef entry id);
    flush stdout;
  match entry with
....

  | `SYMDEF_dcl (`DCL_var t) -> 
    print_endline "Found var";
    print_endline (":--->" ^ string_of_symdef entry id);
    flush stdout;
    bt t

but the print routine looks like:
and string_of_symdef entry name = match entry with
  .....
   | `SYMDEF_dcl d ->
    "declaration " ^ string_of_dcl 0 name d
  ....

and string_of_dcl level name s = 
  let se e = string_of_expr e in
  match s with
...
  | `DCL_proc (args, code) ->
    spaces level ^ 
    "proc " ^ name ^ ": " ^ 
     (string_of_typecode (type_of_argtypes args)) ^
     " = " ^ string_of_string code ^ ";"
...
  | `DCL_var (ty) ->
    spaces level ^ 
    "var " ^ name ^ ": " ^ string_of_typecode ty ^ ";"


The diagnostic listed is the last thing I see before the segfault.
The next call, 

	bt t

should have executed:

    print_endline ("TYPEOFINDEX binding type " ^ string_of_typecode t);
    flush stdout;

but hasn't. It would probably have crashed if it did,
since the type of the variant being passed is wrong.
(Did it crash forming the closure?)

The routine, is, in fact, analysing the "proc print" entry,
so the diagnostic output is correct, and it's the match
in the 'typeofindex' routine that is failing.

I've submitted a bug report, but bugs in Ocaml are rare enough
for me to still believe it is possible that I'm doing something
wrong -- but I have no idea what to try next. The source is
too large for a bug report, and I haven't been able to
reproduce the problem with a tiny test case involving
nested PM variants. It's possible that my problem
is related to Davids (and has nothing to do with PM variants,
which David is not using). As far as I can remember,
my code built fine using 3.01, but it has been rewritten
in the last few weeks: and I installed 3.02 on Aug 4.

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au 
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
New generation programming language Felix  http://felix.sourceforge.net
Literate Programming tool Interscript     
http://Interscript.sourceforge.net
-------------------
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


  parent reply	other threads:[~2001-08-21 19:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-16  8:08 [Caml-list] Segfault in a native code multi-threaded program David Mentre
2001-08-16 12:45 ` Vitaly Lugovsky
2001-08-17  8:09   ` David Mentre
2001-08-17 16:54     ` Brian Rogoff
2001-08-20  9:12       ` David Mentre
2001-08-20 16:54       ` Jun P. FURUSE
2001-08-18 23:15     ` John Max Skaller
2001-08-19  0:24       ` John Gerard Malecki
2001-08-19 18:18         ` [Caml-list] Ocaml ffi release 1.2.2 dsfox
     [not found] ` <3B7C5A74.15141D95@maxtal.com.au>
     [not found]   ` <qtlitfm6ajh.fsf@pochi.inria.fr>
     [not found]     ` <3B7F0C99.FEDEAA86@maxtal.com.au>
     [not found]       ` <qtl3d6m4vkt.fsf@pochi.inria.fr>
2001-08-21 19:20         ` John Max Skaller [this message]
2001-08-23  8:54           ` [Caml-list] Segfault in a native code program using pm variants Xavier Leroy

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=3B82B493.BD6DCA52@maxtal.com.au \
    --to=skaller@maxtal.com.au \
    --cc=David.Mentre@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).