Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • F frama-c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 168
    • Issues 168
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • pub
  • frama-c
  • Issues
  • #2594

Unsafe uses of Obj in Unmarshal

A few pieces of code in the Unmarshal module are too obviously unsafe for the Flambda 2 compiler's taste, and results in the compiler deliberately inserting a segfault. The Sys.opaque_identity function can be used to tell the compiler not to make any assumptions on the underlying value, and is available since OCaml 4.03, so I'd like to see it used here to allow testing Frama C with Flambda 2. The three places that are affected are:

  • The code for initialising arch_bigendian. This can be fixed by inserting a call to Sys.opaque_identity.
  • The code for initialising arch_float_endianness. This can be fixed by inserting a call to Sys.opaque_identity.
  • The code for computing the null value. I assume that the code was intended to compute a null pointer, but it was reading the wrong field anyway so this was instead a pointer to a C-allocated struct (which, it seems, works as well). I'd like to replace it with Obj.repr (Sys.opaque_identity (ref 0)), which should work too (it gives you a unique static pointer) and has the advantage of not manipulating naked pointers.

I could propose a patch if you'd like (or even open a merge request, if your GitLab instance accepts merge requests from external contributors)

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking