Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006108OCamlOCaml generalpublic2013-07-30 21:002014-09-24 00:04
Reportermcclurmc 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusconfirmedResolutionopen 
Platformx86_64OSLinuxOS VersionUbuntu 12.10
Product Version4.00.1 
Target Versionafter-4.02.1Fixed in Version 
Summary0006108: Crash toplevel by using compiler-libs
DescriptionI load compiler-libs into toplevel using topfind:

# #require "compiler-libs.toplevel";;
/home/mike/.opam/4.00.1/lib/ocaml/threads: added to search path
/home/mike/.opam/4.00.1/lib/ocaml/compiler-libs: added to search path
/home/mike/.opam/4.00.1/lib/ocaml/compiler-libs/ocamlcommon.cma: loaded
/home/mike/.opam/4.00.1/lib/ocaml/compiler-libs/ocamlbytecomp.cma: loaded
/home/mike/.opam/4.00.1/lib/ocaml/compiler-libs/ocamltoplevel.cma: loaded


I can then parse a string:

# Parse.implementation (Lexing.from_string "1 :: []") ;;


However, if I try to make a function out of this...

# let parse_string s = s |> Lexing.from_string |> Parse.implementation ;;
>> Fatal error: parse_string unbound at toplevel
Fatal error: exception Misc.Fatal_error
Steps To ReproduceSee description
Additional InformationI can repro this using utop, and ocaml toplevel, with and without topfind.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010023)
gasche (developer)
2013-07-30 21:36

You don't need compiler-libs.toplevel to get a working lexer and parser from the OCaml compiler. You can use compiler-libs.common, which doesn't link the weird stuff from *.toplevel that provokes the failure here.

(I don't really know what happens, but I suppose the toplevel implementation is not re-entrant, and linking some modules from compiler-libs.toplevel affects the global state of the current toplevel. This is not documented nor supported, and I don't really know why you would want to do that.)
(0010081)
doligez (administrator)
2013-08-02 16:29

The toplevel implementation is definitely not re-entrant.
(0010085)
meyer (developer)
2013-08-03 00:37

This definitely needs to be in manual, I might prepare a patch for it myself.

I think it's not well known yet how to use compilelibs, usually it's easier to document tools, howver the great premise of compilerlibs, is that they will make such tasks easier. If it comes additionaly with examples, (for -ppx rewriter for instance) then it's great.

- Issue History
Date Modified Username Field Change
2013-07-30 21:00 mcclurmc New Issue
2013-07-30 21:36 gasche Note Added: 0010023
2013-08-02 16:29 doligez Note Added: 0010081
2013-08-02 16:29 doligez Status new => confirmed
2013-08-02 16:29 doligez Target Version => 4.01.1+dev
2013-08-03 00:37 meyer Note Added: 0010085
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-24 22:54 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-24 00:04 doligez Target Version undecided => after-4.02.1


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker