Skip to content

Add documentation for memory primitives #5333

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

Merged
merged 2 commits into from
May 5, 2020

Conversation

danpoe
Copy link
Contributor

@danpoe danpoe commented May 5, 2020

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • n/a Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good to go.

My only preference would be to pick either cbmc or CBMC and stick with it for all references to it for consistency's sake.

variable would correspond to an object of size 4, and memory allocated via
`malloc(10)` would correspond to an object of size 10.

A pointer then consists of two parts: the upper n bits form the object ID, and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be changed to n?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the n doesn't refer to code or commandline text or something like that so I think it shouldn't be highlighted that way.

@danpoe danpoe force-pushed the docs/memory-primitives branch from 9f4cac8 to ff21d95 Compare May 5, 2020 11:38
@danpoe danpoe marked this pull request as ready for review May 5, 2020 13:00
@danpoe danpoe added the aws Bugs or features of importance to AWS CBMC users label May 5, 2020
\page memory-primitives Memory Primitives

This document describes the semantics and usage of memory-related and
pointer-related primitives in cbmc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pointer-related primitives in cbmc.
pointer-related primitives in CBMC.

# Background


## Memory and pointers in cbmc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Memory and pointers in cbmc
## Memory and Pointers in CBMC

## Memory and pointers in cbmc

When cbmc analyzes a program, by default it uses the architectural parameters of
the platform it is running on. That is, on a 64-bit system, cbmc will treat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the platform it is running on. That is, on a 64-bit system, cbmc will treat
the platform it is running on. That is, on a 64-bit system, CBMC will treat

etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

integer values, and then constrained to negative values via the assumption.
In cbmc, like uninitialized integers, uninitialized pointers are treated as
having a nondeterministic value. That is, the value of the pointer itself is
nondeterministically chosen, though **no memory is allocated**.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe say that you are going to describe what can be expected from an intitialized pointer below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a sentence saying that pointers should be explicitely initialized

allocated memory, or is out of bounds of the memory object it points to (i.e.,
the memory object identified by `__CPROVER_POINTER_OBJECT(p)`).


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe say upfront that some operations, particularly on invalid pointers, are unspecified. Say how I can detect that I have something with unspecified semantics in my harness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@danpoe danpoe force-pushed the docs/memory-primitives branch from ff21d95 to 62a4b55 Compare May 5, 2020 13:51
@danpoe danpoe merged commit 5d4c4a8 into diffblue:develop May 5, 2020
@danpoe danpoe deleted the docs/memory-primitives branch June 2, 2020 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants