Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006108OCamlOCaml generalpublic2013-07-30 21:002015-02-25 09:52
Assigned To 
Platformx86_64OSLinuxOS VersionUbuntu 12.10
Product Version4.00.1 
Target Versionafter-4.02.2Fixed 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
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.)
doligez (administrator)
2013-08-02 16:29

The toplevel implementation is definitely not re-entrant.
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.
erwan (reporter)
2015-02-24 16:54
edited on: 2015-02-24 16:55

Can this bug impact the behavior of ocamlmktop? I have a segv too, and I'd like to know if it can be due to the same origin.

doligez (administrator)
2015-02-24 22:26

Do you mean ocamlmktop itself is segfaulting, or the generated toplevel? I don't think the problem described here can happen to a statically-linked program.
erwan (reporter)
2015-02-25 09:52

In the generated toplevel.

Unfortunately, it's difficult to provide a small example that exhibits the problem as my program is quite big, and the segv occurs seldomly. I should try to load my libs from a standard toplevel to see if segv still occurs.

- 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 => 4.02.2+dev
2015-02-24 16:54 erwan Note Added: 0013332
2015-02-24 16:55 erwan Note Edited: 0013332 View Revisions
2015-02-24 22:26 doligez Note Added: 0013337
2015-02-24 22:26 doligez Target Version 4.02.2+dev => after-4.02.2
2015-02-25 09:52 erwan Note Added: 0013344

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker