Skip to content

Handle empty structs in the back-end (and a number of induced fixes) #2161

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
Oct 31, 2018

Conversation

tautschnig
Copy link
Collaborator

I will need to break this PR apart, but I'll publish it in full for visibility. My original intent was just to fix the problem didn't handle empty structs (regression test included), which causes unnecessary failures in SV-COMP.

While I will split it up to enable reasonable reviewing, it should actually be clean and be ready for an evaluation against test-gen.

@tautschnig
Copy link
Collaborator Author

tautschnig commented May 7, 2018

I have created #2162, #2163, #2164, #2165, #2166 to factor out the initial parts.

@tautschnig tautschnig self-assigned this May 7, 2018
@tautschnig tautschnig force-pushed the empty-struct branch 3 times, most recently from bacc8c1 to 2b09684 Compare June 7, 2018 11:04
@tautschnig tautschnig assigned kroening and unassigned tautschnig Jun 7, 2018
@tautschnig tautschnig force-pushed the empty-struct branch 2 times, most recently from 51c11f8 to 02a13a2 Compare June 14, 2018 08:32
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

This PR failed Diffblue compatibility checks (cbmc commit: 51c11f8).
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

Passed Diffblue compatibility checks (cbmc commit: 02a13a2).

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Couple of things to check, otherwise lgtm

if(cellidx < 0 || !cellidx.is_long())
const array_typet &array_type = to_array_type(source_type);

// no arrays of non-byte, zero-, or unknown-sized objects
Copy link
Contributor

Choose a reason for hiding this comment

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

non-byte-aligned?

main.cpp
-DNO_IO -DNO_STRING
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
--
warning: ignoring byte_extract_little_endian
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean this to be a comment?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah... along with the previous line that does seem a little bizaar.


return object_rec(rest, pointer_type, tmp);
return plus_exprt(
address_of_exprt(deep_object.op0(), pointer_type(char_type())),
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this need an explicit typecast?

@tautschnig
Copy link
Collaborator Author

Needs to be rebased once #3185 is merged.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

A few minor comments. Shouldn't take much after the rebase.

#pragma pack(1)
struct S
{
int x;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I was a complete sadist I might suggest making this an int8_t because then we have to deal with the packing rules around an empty structure. If y was one as well you'd hope that sizeof(struct S) would be sizeof(int8_t) * 2 rather than 2 (or 3) times the minimum alignment unit.

main.cpp
-DNO_IO -DNO_STRING
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
--
warning: ignoring byte_extract_little_endian
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah... along with the previous line that does seem a little bizaar.

return src;
return plus_exprt(
address_of_exprt(deep_object.op0(), pointer_type(char_type())),
from_integer(pointer.offset / subtype_bytes, index_type()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above.


if(
offset * 8 >= m_offset_bits && m_offset_bits % 8 == 0 &&
offset * 8 + target_size <= m_offset_bits + m_size)
Copy link
Collaborator

Choose a reason for hiding this comment

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

8? Are we really hard-coded to have 8-bit bytes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, once #917 is merged (after me reworking some of it) that should no longer be the case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK; I'll leave this one for now.

We now support pointers into structs with zero-sized members, which is a GCC
extension that we otherwise do support.
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: d4296f1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/89834675

@tautschnig tautschnig merged commit d3612cc into diffblue:develop Oct 31, 2018
@tautschnig tautschnig deleted the empty-struct branch October 31, 2018 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants