Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: John Skaller <skaller@ozemail.com.au>
To: caml-announce@inria.fr
Subject: [Caml-list] debugger?
Date: Fri, 20 Jun 2003 13:12:29 +1000	[thread overview]
Message-ID: <3EF27B9D.3060908@ozemail.com.au> (raw)

I have just converted my build system to optionally make
bytecode. When I run the program on one of the larger tests,
I get a stack overflow. The program runs correctly if
I set the stack to 800000 words but not 600000,
it works fine under the optimising compiler.
The test takes a few seconds for the optimising compiler,
and 10 times longer for the bytcode version.
[The other tests seem to run equally fast]

Looks like non-tail recursion in the lexer,
which is the only place there is a 'recursive'
enough data structure to cause a problem:
a list of tokens of the input file.

So I ran the test under the debugger, typed
backtrace when it crashed .. and got no
backtrace.

The time was 12Meg at the crash, so I goto'd
10Meg. Only 6 frames on the stack. No tail
recursion problem. No doubt we're in the
lexer though.

There IS one nasty point in the lexer.
The lexer returns a token list in
reverse order, however, each lexeme
returns a list of tokens in forward order,
so the new list is:

	rev h @ t

The lexer is recursive with respect to #include files.
[I'm replacing the above with rev_append ..]
So there are a few rather large 'rev's happening.
In the test case though, its the same include file
as the other tests ..

let pre_tokens_of_lexbuf buf state =
     let rec get lst =
       let ts = pre_flx_lex buf state in
       match ts with
       | [Flx_parse.ENDMARKER] -> lst
       | _ -> get (List.rev_append ts lst)
     in List.rev (get [])


(ocd) run
Loading program... done.
EXCEPTION
Stack overflow
Time : 12161027
Program exit.
(ocd) bt
(ocd) bt 20
(ocd) The program is running. Quit anyway ? (y or n) y
[skaller@pelican] ~/links/flx>ocamldebug -I src bin/flxg -Ilib test/rt01
	Objective Caml Debugger version 3.06+34 (2003-05-21)

(ocd) go 10000000
Loading program... done.
Time : 10000000 - pc : 290304 - module Flx_lex
48       Lexing.lexeme_end lexbuf<|a|> - buf_pos
(ocd) bt
#0  Pc : 290304  Flx_lex char 1167
#1  Pc : 278484  Flx_lex char 156528
#2  Pc : 295344  Flx_pretok char 5616
#3  Pc : 295588  Flx_pretok char 5758
#4  Pc : 295288  Flx_pretok char 6000
#5  Pc : 307460  Flx_parse_ctrl char 277
#6  Pc : 569696  Flxg char 2419
-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


                 reply	other threads:[~2003-06-20  3:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3EF27B9D.3060908@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --cc=caml-announce@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