Skip to content

goto_rw/range_spect: gracefully handle arbitrarily large ranges #6768

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions regression/cbmc/havoc_slice_checks/full-slice.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CORE
main.c
--full-slice
^\[main\.assertion\.\d+\] line 9 assertion havoc_slice W_OK.*: FAILURE$
^\[main\.assertion\.\d+\] line 13 assertion havoc_slice W_OK.*: FAILURE$
^\[main\.assertion\.\d+\] line 18 assertion havoc_slice W_OK.*: FAILURE$
^\[main\.assertion\.\d+\] line 21 assertion havoc_slice W_OK.*: FAILURE$
^\[main\.assertion\.\d+\] line 24 assertion havoc_slice W_OK.*: FAILURE$
^\[main\.assertion\.\d+\] line 27 assertion havoc_slice W_OK.*: FAILURE$
^\[main\.assertion\.\d+\] line 30 assertion havoc_slice W_OK.*: FAILURE$
\*\* 7 of [0-9]+ failed \(.*\)
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
16 changes: 13 additions & 3 deletions src/analyses/goto_rw.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,20 @@ class range_spect

static range_spect to_range_spect(const mp_integer &size)
{
PRECONDITION(size.is_long());
// The size need not fit into the analysis platform's width of a signed long
// (as an example, it could be an unsigned size_t max, or perhaps the source
// platform has much wider types than the analysis platform.
if(!size.is_long())
Copy link
Member

Choose a reason for hiding this comment

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

❓ When wouldn't it be a long? A comment would help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment added, including an example. (A signed long, for example, isn't sufficient to capture a maximum size_t value.)

return range_spect::unknown();

mp_integer::llong_t ll = size.to_long();
CHECK_RETURN(ll <= std::numeric_limits<range_spect::value_type>::max());
CHECK_RETURN(ll >= std::numeric_limits<range_spect::value_type>::min());
if(
ll > std::numeric_limits<range_spect::value_type>::max() ||
ll < std::numeric_limits<range_spect::value_type>::min())
{
return range_spect::unknown();
}

return range_spect{(value_type)ll};
}

Expand Down