| Anonymous | Login | Signup for a new account | 2013-05-23 05:47 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0004966 | OCaml | Camlp4 | public | 2010-01-26 01:28 | 2012-09-25 20:07 | |||
| Reporter | bluestorm | |||||||
| Assigned To | ertai | |||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | ||||||||
| Target Version | Fixed in Version | |||||||
| Summary | 0004966: Camlp4 loops endlessly due to faulty "ignore_upto" function : | |||||||
| Description | The ignore_upto of the stream testers (ugly camlp4 hacks by themselves) are faulty : they do not handle the "EOI" token gracefully, leading in some case to diverging loops. Camlp4ListComprehension and Camlp4OCamlParser are affected, 3.10, 3.11 and Ocaml SVN trunk. See "additional information" for tests and a fix. | |||||||
| Additional Information | Here is a two-lines (incorrect) caml code leading to an infinite loop when parsed by camlp4o : class type foo = object end class test : [int -> foo = fun n -> object end The loops is caused by the "[" : at this syntaxic position is a "test_ctyp_minusgreater" stream test, using the faulty "ignore-upto" function. Here is the faulty ignore_upto code : and ignore_upto end_kwd n = match stream_peek_nth n strm with [ Some (KEYWORD prm) when prm = end_kwd -> n | Some (KEYWORD ("[" | "[<")) -> ignore_upto end_kwd (ignore_upto "]" (n + 1) + 1) | Some (KEYWORD "(") -> ignore_upto end_kwd (ignore_upto ")" (n + 1) + 1) | Some _ -> ignore_upto end_kwd (n + 1) | None -> raise Stream.Failure ] in Here is a (hopefully) correct fix : and ignore_upto end_kwd n = match stream_peek_nth n strm with [ Some (KEYWORD prm) when prm = end_kwd -> n | Some (KEYWORD ("[" | "[<")) -> ignore_upto end_kwd (ignore_upto "]" (n + 1) + 1) | Some (KEYWORD "(") -> ignore_upto end_kwd (ignore_upto ")" (n + 1) + 1) | Some (KEYWORD "{") -> ignore_upto end_kwd (ignore_upto "}" (n + 1) + 1) | None | Some EOI -> raise Stream.Failure | Some _ -> ignore_upto end_kwd (n + 1) ] The only change being the new (Some EOI) pattern. This bug is also present in Camlp4ListComprehension, in wich the same ignore_upto code is reproduced verbatim. Here is a test: camlp4o -parser Camlp4ListComprehension -str '[ x | (x <- l ]' Same cause, same fix. The faulty code is still present in Ocaml SVN trunk, so I suppose it wasn't fixed. The bug was originally reported by Tiphaine Turpin on the "Batteries" project bug tracker : the buggy file, pa_comprehension.ml, use code borrowed from Camlp4ListComprehension. | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0005558) ertai (developer) 2010-06-16 11:51 |
Fixed. Thanks for the report. Thanks to the new TRY feature. We gotten rid of this hack, and as we say: "Code removed is code debugged!" |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2010-01-26 01:28 | bluestorm | New Issue | |
| 2010-01-26 01:28 | bluestorm | Status | new => assigned |
| 2010-01-26 01:28 | bluestorm | Assigned To | => ertai |
| 2010-06-16 11:51 | ertai | Note Added: 0005558 | |
| 2010-06-16 11:51 | ertai | Status | assigned => resolved |
| 2010-06-16 11:51 | ertai | Resolution | open => fixed |
| 2012-09-25 20:07 | xleroy | Status | resolved => closed |
| Copyright © 2000 - 2011 MantisBT Group |