From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id FAA05529; Fri, 20 Jun 2003 05:12:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA05200 for ; Fri, 20 Jun 2003 05:12:42 +0200 (MET DST) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5K3CeT17382 for ; Fri, 20 Jun 2003 05:12:41 +0200 (MET DST) Received: from ozemail.com.au (203-213-127-195-syd-ts20-2600.tpgi.com.au [203.213.127.195]) (authenticated (0 bits)) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h5K3CaN20039 for ; Fri, 20 Jun 2003 13:12:37 +1000 Message-ID: <3EF27B9D.3060908@ozemail.com.au> Date: Fri, 20 Jun 2003 13:12:29 +1000 From: John Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: caml-announce@inria.fr Subject: [Caml-list] debugger? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ozemail:01 debugger:01 optionally:01 800000:99 optimising:01 recursion:01 backtrace:01 meg:99 flx:01 endmarker:01 pelican:01 ocamldebug:01 3.06:01 char:01 pretok:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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