Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restores unit tracking in the plugin facility #1548

Merged

Conversation

ivg
Copy link
Member

@ivg ivg commented Aug 19, 2022

After we switched to OCaml 4.08 and above, we trashed custom unit tracking from our plugin system and started to rely on the Dynlink facility, provided by OCaml, that offers precise unit tracking. However, Dynlink is not allowed inside OCaml Toplevel, which wasn't noticed, because it wasn't properly initialized (though apparently, it worked fine for our needs). But after 4.12 (see ocaml/ocaml#9790) it was properly initialized so we started to get "The dynlink.cma library cannot be used inside the OCaml toplevel" messages when trying to use baptop or bap.top. A quick-fix (#1541) did only worse as it disabled any unit tracking and enabled double-loading of plugins and libraries (which is perfectly allowed in OCaml toplevel and is not a bug, as it was in regular OCaml runtime). Of course, double-loading could crash bap as many of bap libraries have their own state, which got reset after reloading.

This PR restores the old findlib-based unit tracker. This tracker is not precise and may still miss loaded units. For example, if you load bap manually and then do #require "bap.top" it will reload bap (which should not be a problem, but who knows). With that said, we had used this tracker for many years, up until BAP 2.4.0, so I do have some trust in it. Also, I don't want to invest more time in this issue as we are in the process of switching to dune and the dune plugin system (which has its own unit tracking system that is precise). To be honest, dune plugins also do not work in toplevel right now, but this is a developing story (ocaml/dune#6081) and I hope that eventually, we will have it working.

After we switched to OCaml 4.08 and above, we trashed custom unit
tracking from our plugin system and started to rely on the Dynlink
facility, provided by OCaml, that offers precise unit
tracking. However, Dynlink is not allowed inside OCaml Toplevel, which
wasn't noticed, because it wasn't properly initialized (though
apparently it worked fine for our needs). But after 4.12
(see ocaml/ocaml#9790) it was properly
initialized so we started to get "The dynlink.cma library cannot be used
inside the OCaml toplevel" messages when trying to use `baptop` or
`bap.top`. A quick-fix (BinaryAnalysisPlatform#1541) did only worse as it disabled any unit
tracking and enabled double-loading of plugins and libraries (which is
perfectly allowed in OCaml toplevel and is not a bug, as it was in
regular OCaml runtime). Of course, double-loading could crash bap as
many of bap libraries have their own state, which got reset after
reloading.

This PR restores the old findlib-based unit tracker. This tracker is
not precise and may still miss loaded units. For example, if you load
bap manually and the do `#require "bap.top"` it will reload bap (which
should be a problem, but who knows). With that said, we had used this
tracker for many years, up until BAP 2.4.0, so I do have some trust in
it. Also, I don't want to invest more time in this issue as we are in
the process of switching to dune and thhe dune plugin system (that has
its own unit tracking system, which is precise). To be honest, dune
plugins also do not work in toplevel right now, but this is a
developing story (ocaml/dune#6081) and I
hope that eventually we will have it working.
@ivg ivg merged commit 90d3d0e into BinaryAnalysisPlatform:master Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant