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

OCaml DSL for specifying LibraryFunctions #720

Merged
merged 74 commits into from
Jun 16, 2022
Merged

OCaml DSL for specifying LibraryFunctions #720

merged 74 commits into from
Jun 16, 2022

Conversation

sim642
Copy link
Member

@sim642 sim642 commented May 4, 2022

This is an experiment to address #719 by designing an OCaml DSL, which allows specifying LibraryFunctions such that all the problems mentioned in the issue are avoided and all the goals are fulfilled.

The DSL implementation is a mixture of the following:

  • So-called first-class patterns inspired by ppxlib's Ast_pattern: https://github.com/ocaml-ppx/ppxlib/blob/main/src/ast_pattern.ml. The three-type-parameter continuation-based internals of the patterns are hidden from actually specifying functions.
  • A custom list-like type (using the standard list constructors to allow abusing normal OCaml list notation), but as a GADT to allow composing the first-class patterns in a type-safe manner. The GADT internals are hidden from actually specifying functions.
  • A set of helper functions to construct such specifications in a readable way.

The DSL in LibraryDsl is just a convenient way to construct newly-introduced LibraryDesc objects, which combine the corresponding classify function, invalidate actions (with more precision) and other function-related attributes (e.g. being thread unsafe #723 or invalidating all globals).

The usage is (hopefully sufficiently) extensively documented both in the OCaml code and in the developer documentation.
The usage can be seen at the beginning of LibraryFunctions and LibraryDslTest.

TODO

  • Document LibraryDesc.
  • Document LibraryDsl.
  • Implement shallow vs deep distinction in access analysis correctly. Function arguments are always directly read on call, but the access depth actually concerns MPT/reach. So there are actually three levels of access for reading function arguments.
  • Fix new "Function definition missing" errors.
  • Separate specifications lists:
    • C standard library
    • POSIX standard library
    • Pthread
    • Linux kernel
  • Add selection for separate specifications lists. To be done in the future, when all old-style specifications have been ported.

@sim642 sim642 added cleanup Refactoring, clean-up feature type-safety Type-safety improvements precision labels May 4, 2022
@sim642 sim642 self-assigned this May 4, 2022
sim642 added 19 commits May 12, 2022 11:14
reach is true only if deref is also.
Invalidation should also be done for special (non-Unknown) functions that symb_locks doesn't handle before.
Spawning should also be done for special (non-Unknown) functions that forkfun doesn't handle before.
This now works using standard invalidation.
@sim642 sim642 merged commit 08fdb65 into master Jun 16, 2022
@sim642 sim642 deleted the library-dsl branch June 16, 2022 09:18
sim642 added a commit that referenced this pull request Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Refactoring, clean-up feature precision type-safety Type-safety improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign of LibraryFunctions specification
2 participants