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

Compilation does not terminate #97

Closed
pqwy opened this issue Dec 1, 2015 · 3 comments
Closed

Compilation does not terminate #97

pqwy opened this issue Dec 1, 2015 · 3 comments

Comments

@pqwy
Copy link

pqwy commented Dec 1, 2015

More precisely, compilation time is exponential in the constant given to fun1 in this program:

let app fb x = fb x

let rec fun1 = function
  | 0 -> ()
  | n -> app (fun _ -> fun1 (pred n)) ()

let _ = app (fun () -> fun1 1000000) ()

Attaching gdb, the stack is 4144 deep, with this at the top:

#0  0x00000000006bc8a8 in caml_oldify_one ()
#1  0x00000000006bcaea in caml_oldify_mopup ()
#2  0x00000000006bcbb0 in caml_empty_minor_heap ()
#3  0x00000000006bcda9 in caml_minor_collection ()
#4  0x00000000006bb87a in caml_garbage_collection ()
#5  0x00000000006cd514 in caml_call_gc ()
#6  0x0000000000444491 in camlFreshening__func_decls_subst_closure_5785 () at middle_end/freshening.ml:286
#7  0x000000000044465c in camlFreshening__apply_function_decls_and_free_vars_closure_5991 ()
    at middle_end/freshening.ml:306
#8  0x0000000000475df5 in camlInline_and_simplify__simplify_set_of_closures_28040 ()
    at middle_end/inline_and_simplify.ml:571
#9  0x000000000047569e in camlInline_and_simplify__simplify_named_28045 () at middle_end/inline_and_simplify.ml:847
#10 0x00000000004783cc in camlInline_and_simplify__for_defining_expr_closure_29729 ()
    at middle_end/inline_and_simplify.ml:928
#11 0x000000000043307f in camlFlambda__loop_18560 () at middle_end/flambda.ml:834
#12 0x000000000047476d in camlInline_and_simplify__simplify_28048 () at middle_end/inline_and_simplify.ml:1186
#13 0x0000000000473ede in camlInline_and_simplify__simplify_function_closure_28679 ()
    at middle_end/inline_and_simplify.ml:626
#14 0x0000000000688654 in camlMap__fold_4315 () at map.ml:193
#15 0x0000000000476053 in camlInline_and_simplify__simplify_set_of_closures_28040 ()
    at middle_end/inline_and_simplify.ml:644
#16 0x000000000047569e in camlInline_and_simplify__simplify_named_28045 () at middle_end/inline_and_simplify.ml:847
#17 0x00000000004783cc in camlInline_and_simplify__for_defining_expr_closure_29729 ()
    at middle_end/inline_and_simplify.ml:928
#18 0x000000000043307f in camlFlambda__loop_18560 () at middle_end/flambda.ml:834
#19 0x000000000047476d in camlInline_and_simplify__simplify_28048 () at middle_end/inline_and_simplify.ml:1186
#20 0x0000000000473ede in camlInline_and_simplify__simplify_function_closure_28679 ()
    at middle_end/inline_and_simplify.ml:626
#21 0x0000000000688654 in camlMap__fold_4315 () at map.ml:193
#22 0x0000000000476053 in camlInline_and_simplify__simplify_set_of_closures_28040 ()
    at middle_end/inline_and_simplify.ml:644
#23 0x000000000047569e in camlInline_and_simplify__simplify_named_28045 () at middle_end/inline_and_simplify.ml:847
#24 0x00000000004783cc in camlInline_and_simplify__for_defining_expr_closure_29729 ()
    at middle_end/inline_and_simplify.ml:928
#25 0x000000000043307f in camlFlambda__loop_18560 () at middle_end/flambda.ml:834

Using version 4.03.0+dev11-2015-10-19, the one currently in opam.

@pqwy
Copy link
Author

pqwy commented Dec 1, 2015

In addition, using -no-functor-heuristics prevents this issue.

@mshinwell
Copy link
Collaborator

The toplevel function is being caught by the functor heuristics, even though it is not a functor, I presume. I think the forthcoming work to functor heuristics should fix this, at which point we should retest this example.

@mshinwell
Copy link
Collaborator

I tested this and it appears to have been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants