Skip to content

[TG-1121] Bugfix for multi-dimensional arrays with non-const size and non-const access #2173

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 4 commits into from
May 21, 2018
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
KNOWNBUG
CORE
FloatMultidim1.class
--function FloatMultidim1.f --cover location --unwind 3
\d+ of \d+ covered
^EXIT=0$
^SIGNAL=0$
--
--
This crashes during symex, with error 'cannot unpack array of nonconst size'
when trying to access the element of the array. Symex uses byte_extract_little
_endian to access the element which does not get simplified (it seems the
problem is that the types in the instruction do not match). TG-1121
y=1$
y=[2-4]$
y=([05-9]|[1-9][0-9]+|-[1-9][0-9]*)$
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
KNOWNBUG
CORE
RefMultidim1.class
--function RefMultidim1.f --cover location --unwind 3
\d+ of \d+ covered
^EXIT=0$
^SIGNAL=0$
--
--
This crashes during symex, with error 'cannot unpack array of nonconst size'
when trying to access the element of the array. Symex uses byte_extract_little
_endian to access the element which does not get simplified (it seems the
problem is that the types in the instruction do not match). TG-1121
y=1$
y=[2-4]$
y=([05-9]|[1-9][0-9]+|-[1-9][0-9]*)$
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
KNOWNBUG
CORE
RefMultidim2.class
--function RefMultidim2.f --cover location --unwind 3
\d+ of \d+ covered
^EXIT=0$
^SIGNAL=0$
--
--
This crashes during symex, with error 'cannot unpack array of nonconst size'
when trying to access the element of the array. Symex uses byte_extract_little
_endian to access the element which does not get simplified (it seems the
problem is that the types in the instruction do not match). TG-1121
y=1$
y=[2-4]$
y=([05-9]|[1-9][0-9]+|-[1-9][0-9]*)$
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
CORE
TestClass.class
--function TestClass.f --cover location --unwind 2
Source GOTO statement: .*
(^ exception: Can't convert byte_extraction|Nested exception printing not supported on Windows)
^EXIT=6$
--
--
The exception thrown in this test is the symptom of a bug; the purpose of this
test is the validate the output of that exception
^EXIT=0$
^SIGNAL=0$
34 changes: 32 additions & 2 deletions src/pointer-analysis/value_set_dereference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,38 @@ bool value_set_dereferencet::dereference_type_compare(
const typet &object_type,
const typet &dereference_type) const
{
if(dereference_type.id()==ID_empty)
return true; // always ok
// check if the two types have matching number of ID_pointer levels, with
// the dereference type eventually pointing to void; then this is ok
// for example:
// - dereference_type=void is ok (no matter what object_type is);
// - object_type=(int *), dereference_type=(void *) is ok;
// - object_type=(int **), dereference_type=(void **) is ok;
// - object_type=(int **), dereference_type=(void *) is ok;
// - object_type=(int *), dereference_type=(void **) is not ok;
const typet *object_unwrapped = &object_type;
const typet *dereference_unwrapped = &dereference_type;
while(object_unwrapped->id() == ID_pointer &&
dereference_unwrapped->id() == ID_pointer)
{
object_unwrapped = &object_unwrapped->subtype();
dereference_unwrapped = &dereference_unwrapped->subtype();
}
if(dereference_unwrapped->id() == ID_empty)
{
return true;
}
else if(dereference_unwrapped->id() == ID_pointer &&
object_unwrapped->id() != ID_pointer)
{
#ifdef DEBUG
std::cout << "value_set_dereference: the dereference type has "
"too many ID_pointer levels"
<< std::endl;
std::cout << " object_type: " << object_type.pretty() << std::endl;
std::cout << " dereference_type: " << dereference_type.pretty()
<< std::endl;
#endif
}

if(base_type_eq(object_type, dereference_type, ns))
return true; // ok, they just match
Expand Down