Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000460OCamlOCaml generalpublic2001-07-30 15:532014-10-10 12:45
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000460: 3.02 compiler overflows stack on *.mli
Description
Dear OCaml implementors,

the OCaml 3.02 compiler does not like to compile this interface if a
compiled interface already exists:

/tmp > cat test.mli
module type MM = sig
end

module A : sig
  module type T = sig
     module T : MM
  end
end

module EmptyT : A.T

/tmp > ocamlc -c -g test.mli # first time - works ok
/tmp > ocamlc -c -g test.mli # opens test.cmi over and over
Uncaught exception: Stack overflow
/tmp > ocamlc -c -g test.mli
Uncaught exception: Stack overflow
/tmp > rm test.cmi # remove test.cmi
/tmp > ocamlc -c -g test.mli # works again
/tmp > ocamlc -c -g test.mli # does not work
Uncaught exception: Stack overflow

Although I don't believe that this problem is system dependent, here is
my configuration from ./configure:

    Directories where Objective Caml will be installed:
            binaries.................. /usr/local/bin
            standard library.......... /usr/local/lib/ocaml
            manual pages.............. /usr/local/man/man1 (with extension .1)
    Configuration for the bytecode compiler:
            C compiler used........... gcc
            options for compiling..... -fno-defer-pop -Wall -Wno-unused
            options for linking....... -lm -lcurses
    Configuration for the native-code compiler:
            hardware architecture..... i386
            OS variant................ linux_elf
            C compiler used........... gcc
            options for compiling..... -Wall -Wno-unused
            options for linking....... -lm
            assembler ................ $(AS)
            preprocessed assembler ... gcc -c -DSYS_$(SYSTEM)
            profiling with gprof ..... supported
    Source-level replay debugger: supported
    Configuration for the external libraries:
            libraries supported ...... unix str num dynlink bigarray threads
                                       graph dbm
    The "num" library:
            target architecture ...... x86
    The "graph" library:
            options for compiling .... -I/usr/X11R6/include
            options for linking ...... -ccopt -L/usr/X11R6/lib -cclib -lX11
    The "labltk" library: configuration failed

The following gcc was used to compile OCaml:

    gcc version 2.95.2 20000220 (Debian GNU/Linux)

-- Christian

--
Christian Lindig Harvard University - DEAS
lindig@eecs.harvard.edu 33 Oxford St, MD 242, Cambridge MA 02138
phone: +1 (617) 496-7157 http://www.eecs.harvard.edu/~lindig/ [^]

TagsNo tags attached.
Attached Files

- Relationships
related to 0006600feedbackgarrigue -short-paths slow :( 

-  Notes
(0000627)
administrator (administrator)
2001-07-31 10:23

> the OCaml 3.02 compiler does not like to compile this interface if a
> compiled interface already exists:
>
> /tmp > cat test.mli
> module type MM = sig
> end
>
> module A : sig
> module type T = sig
> module T : MM
> end
> end
>
> module EmptyT : A.T
>
> /tmp > ocamlc -c -g test.mli # first time - works ok
> /tmp > ocamlc -c -g test.mli # opens test.cmi over and over
> Uncaught exception: Stack overflow

That's a very interesting bug, and I believe it's been around for
years -- probably since Caml Special Light. I think I have fixed it.
Since you're obviously using the module system intensively, would you
agree to test the fix? The patch (against 3.02) is attached below.

(One reason I'm asking you to test is that the fix renders module
type-checking exponential in the nesting depth of structures, I think
that should be OK in practice, but if you notice a major slowdown,
please tell me and I'll try to address the efficiency issue.)

Best wishes,

- Xavier Leroy

Index: typing/env.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/env.ml,v
retrieving revision 1.38
diff -u -r1.38 env.ml
--- typing/env.ml 2000/04/10 14:59:00 1.38
+++ typing/env.ml 2001/07/31 08:17:07
@@ -465,7 +465,7 @@
             let comps = components_of_module !env sub path mty in
             c.comp_components <-
               Tbl.add (Ident.name id) (comps, !pos) c.comp_components;
- env := store_components id path comps !env;
+ env := store_module id path mty !env;
             incr pos
         | Tsig_modtype(id, decl) ->
             let decl' = Subst.modtype_declaration sub decl in
@@ -591,18 +591,6 @@
     classes = env.classes;
     cltypes = env.cltypes;
     summary = Env_modtype(env.summary, id, info) }
-
-and store_components id path comps env =
- { values = env.values;
- constrs = env.constrs;
- labels = env.labels;
- types = env.types;
- modules = env.modules;
- modtypes = env.modtypes;
- components = Ident.add id (path, comps) env.components;
- classes = env.classes;
- cltypes = env.cltypes;
- summary = env.summary }
 
 and store_class id path desc env =
   { values = env.values;

(0000628)
administrator (administrator)
2001-07-31 14:58

 > (One reason I'm asking you to test is that the fix renders module
 > type-checking exponential in the nesting depth of structures, I think
 > that should be OK in practice, but if you notice a major slowdown,
 > please tell me and I'll try to address the efficiency issue.)

I have noticed a significant slowdown, but it is a slowdown I can live
with. Of the following two files, newlib.ml is almost entirely
`module stitchery', whereas luainterp.ml has lots of `real' code.
The difference is that newlib contains a number of modules nested to
depth 4, where luainterp contains modules nested to depth at most 2,
and most of the code is at depth 1.

  : nr@labrador 13072 ; /usr/bin/time ocamlc -I ../lib -g -c luainterp.ml
  1.48user 0.01system 0:01.50elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
  0inputs+0outputs (129major+1385minor)pagefaults 0swaps
  : nr@labrador 13073 ; /usr/bin/time ocamlc -I ../lib -g -c newlib.ml
  3.95user 0.04system 0:04.02elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
  0inputs+0outputs (129major+1736minor)pagefaults 0swaps
  : nr@labrador 13074 ; wc luainterp.ml newlib.ml
      525 3523 18821 luainterp.ml
      366 1988 12421 newlib.ml
      891 5511 31242 total

I'll happily send the files if you wish to investigate.


Norman

(0000629)
administrator (administrator)
2001-07-31 18:42

Fixed 2001-07-31 by XL.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2014-10-10 12:45 garrigue Relationship added related to 0006600


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker