Skip to content
New issue

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

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

Already on GitHub? # to your account

Stack_overflow exception #410

Closed
rlepigre opened this issue Jan 25, 2016 · 5 comments
Closed

Stack_overflow exception #410

rlepigre opened this issue Jan 25, 2016 · 5 comments

Comments

@rlepigre
Copy link

We are having trouble with a Stack_overflow exception that we cannot trace... There is no
problem with the OCaml version and the stack size is reasonable. Other than polymorphic hash and equality function, are there other possible cause for such an error? Is there support for debuging of some kind in js_of_ocaml? For instance, is there a way to print a backtrace?

@hhugo
Copy link
Member

hhugo commented Jan 26, 2016

Common culprit is that tail call is not optimized in general. You may face the same issue as #357

You can use Js.debugger () (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/debugger) to set a breakpoint.

You should be able to print to callstack with the following

Firebug.console##error (new%js Js.error_constr (Js.string ""))

@rlepigre
Copy link
Author

OK, then that's a real problem. Our program relies on a parser combinator libraries with many self-recursive functions. Is there a deep technical reason for js_of_ocaml not to optimize tail calls? Would it be difficult to patch it?

@foretspaisibles
Copy link

I also have the same problem and the same questions.! :) It would be nice to hear about the possibly technical reasons why tail calls are not optimised?

(Also, I am a bit confused by the latter. I have zero knowledge about the zinc machine, but I would have expected the tail optimisation to occur before the generation of byte-code. Can anyone comment on this?)

@foretspaisibles
Copy link

If I understand correctly, the file js_tailcall.ml is missing the following implementation, right?

module While : TC = struct
  let rewrite _closures _get_prim = failwith "todo"
end

@hhugo
Copy link
Member

hhugo commented Jun 18, 2016

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants