caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] debugger?
@ 2003-06-20  3:12 John Skaller
  0 siblings, 0 replies; only message in thread
From: John Skaller @ 2003-06-20  3:12 UTC (permalink / raw)
  To: caml-announce

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-06-20  3:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-20  3:12 [Caml-list] debugger? John Skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).