Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocamlc infinite loop in signature matching #3611

Closed
vicuna opened this issue Aug 31, 2002 · 7 comments
Closed

ocamlc infinite loop in signature matching #3611

vicuna opened this issue Aug 31, 2002 · 7 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 31, 2002

Original bug ID: 1360
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Tim Freeman
Version: 3.06
OS: Linux
Submission from: adsl-64-161-114-6.dsl.snfc21.pacbell.net (64.161.114.6)

Put this text in a file and pass it to ocamlc. It will run forever.
The loop doesn't happen if I don't say that the module Argdesc has signature
argdesc, so it looks like a loop in signature matching.
I have reproduced the problem with both ocaml 3.06 from Debian, and with
the CVS version, updated as of this morning.

module type Conscious = sig
type eventtype = [SCALAR | UNIT]
type 'a eventid
class type formatter =
object
(* Next line is needed. *)
method format_eventid_tag: 'a . ([< eventtype] as 'a) eventid -> unit
end

class type ['a] eventdesc =
object
method dump: formatter -> unit
end

class type scalar_eventdesc =
object
inherit ['a] eventdesc
end

class type unit_eventdesc =
object
inherit ['a] eventdesc
end

class virtual ['a] eventdesc_impl:
object
method virtual dump: formatter -> unit
end

class virtual unit_eventdesc_impl:
object ('a)
inherit [[`UNIT]] eventdesc_impl
end
end

module type argdesc = sig
type 'a atom
val log_method: Conscious.unit_eventdesc atom -> unit
val log_new: Conscious.scalar_eventdesc atom -> unit
class function_argdesc: Conscious.unit_eventdesc
end

module Argdesc: argdesc = struct
module C = Conscious
type 'a atom
let log_new (atom: C.scalar_eventdesc atom): unit = ()
let log_method (atom: C.unit_eventdesc atom): unit = ()
class function_argdesc =
object (this)
inherit C.unit_eventdesc_impl
method dump (formatter:C.formatter): unit = ()
end
end

@vicuna
Copy link
Author

vicuna commented Sep 2, 2002

Comment author: administrator

Thanks for uncovering this subtle problem.
A missing check allowed to build a cyclic data structure.
This is now fixed in CVS.

Happy hacking!

 Jacques

@vicuna
Copy link
Author

vicuna commented Sep 2, 2002

Comment author: administrator

Fixed by JG (2002-09-02)

@vicuna vicuna closed this as completed Sep 2, 2002
@vicuna
Copy link
Author

vicuna commented Sep 2, 2002

Comment author: administrator

OCAML doesn't compile itself any more.

From: Jacques Garrigue caml-bugs@pauillac.inria.fr

A missing check allowed to build a cyclic data structure.
This is now fixed in CVS.

I did a "cvs update" and then "make clean" and then "make world", and
it hanged during the "make world". I aborted it and did a "make
world" again and it hanged again in the same place. Here's the tail
of the output from the last make. I tried compiling the same file
with an ocamlc from CVS sometime before Aug. 24 and it completed
in less than a second, so the problem is recently introduced.

make[2]: Nothing to be done for all'. make[2]: Leaving directory /home/tim/ocaml-anon-cvs/ocaml.safe/otherlibs/labltk/tkanim'
cd browser; make
make[2]: Entering directory `/home/tim/ocaml-anon-cvs/ocaml.safe/otherlibs/labltk/browser'
../../../ocamlcomp.sh -c -warn-error A -I ../../unix -I ../../str -I ../labltk -I ../lib -I ../support -I ../../../parsing -I ../../../utils -I ../../../typing searchid.ml

--
Tim Freeman
tim@fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78

@vicuna
Copy link
Author

vicuna commented Sep 2, 2002

Comment author: administrator

From: Jacques Garrigue garrigue@kurims.kyoto-u.ac.jp

I now understand why gcc insists on having you put parentheses around
&& and ||. Even if you know the priorities, you may write wrong code
once a year...

Fixed again. Thanks for your prompt report.

Are you sure you committed the fix? I don't see changed behavior, and
I don't see another change to typing/ctype.ml. The only other
hypothesis is that the dependencies are bad enough that the change is
there but it's not going to get compiled unless I do "make clean; make
world", but I don't have time for that right now. And it's hard to
believe that the dependencies would be that wrong.

--
Tim Freeman
tim@fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78

@vicuna
Copy link
Author

vicuna commented Sep 2, 2002

Comment author: administrator

The only other hypothesis is that the dependencies are bad enough that
the change is there but it's not going to get compiled unless I do
"make clean; make world", but I don't have time for that right now.

I suppose I was lying about not having time, because I did the "make
clean; make world". The behavior is unchanged, so the problem is not
strange make dependencies.

--
Tim Freeman
tim@fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78

@vicuna
Copy link
Author

vicuna commented Sep 3, 2002

Comment author: administrator

From: tim@fungible.com

OCAML doesn't compile itself any more.

Great!

From: Jacques Garrigue caml-bugs@pauillac.inria.fr

A missing check allowed to build a cyclic data structure.
This is now fixed in CVS.

And I added a loop simultaneoulsy.
I now understand why gcc insists on having you put parentheses around
&& and ||. Even if you know the priorities, you may write wrong code
once a year...

Fixed again. Thanks for your prompt report.

  Jacques

@vicuna
Copy link
Author

vicuna commented Sep 3, 2002

Comment author: administrator

From: tim@fungible.com (Tim Freeman)

Are you sure you committed the fix? I don't see changed behavior, and
I don't see another change to typing/ctype.ml.

camlcvs is not the real source tree, but a copy of it.
It may take a few hours before the changes appear there.
Here is the very small patch.

Index: typing/ctype.ml

RCS file: /net/pauillac/caml/repository/csl/typing/ctype.ml,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -r1.142 -r1.143
--- ctype.ml 2002/09/02 03:41:14 1.142
+++ ctype.ml 2002/09/03 02:31:09 1.143
@@ -1656,7 +1656,7 @@
| Reither(c1, tl1, m1, e1), Reither(c2, tl2, m2, e2) ->
if e1 == e2 then () else
let redo =

  •    m1 || m2 &&
    
  •    (m1 || m2) &&
       match tl1 @ tl2 with [] -> false
       | t1 :: tl ->
           if c1 || c2 then raise (Unify []);
    

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant