-
Notifications
You must be signed in to change notification settings - Fork 273
[TG-1422] Bugfix for a precondition fail in the interpreter after generics support has been introduced #1595
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
Conversation
… and modify the concretisation process to use it.
…pression for a concrete generic type.
As urgent as it may be: this has conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be at least two problems here:
- A dependency from goto-programs on java_bytecode is introduced. (There may be a case for moving java_types.h to util/.)
- If code taking the address of a struct is generated, then this code must be fixed rather than weakening the preconditions elsewhere. Taking the address of a non-lvalue never is valid code.
@tautschnig I don't believe anyone is taking the address of a struct. The problem is aliasing incompatible types. If I had a C program:
...then symex would turn The current Java generics code is running into the same problem because it uses unrelated types to represent The long-term fix is to either restructure generics so that existing code for handling inheritance deals with the situation, or else to teach symex about type specialisations. Meanwhile I'll suggest hacking the trace in test-gen to remove casts and make it acceptable to the current GOTO interpreter. |
I don't see a problem with typecasts per se, but here we are talking about the function |
It would be better named |
Indeed; wasn't the precondition introduced in 520cf38 actually always too strong? I'd say the correct fix is to drop the precondition altogether, which would right away also resolve my other concerns about introducing Java-specifics into |
That would be ok with me, though I still think generics long-term need encoding in a way that symex understands. (In particular some type attribute indicating that as a specialisation of another type it matches it in field names, field widths etc, so it always suffices to cast the member rather than cast the whole struct) |
The workaround for the problem that we have is going to be fixed with the way that was suggested, removing the strong precondition, rendering this PR invalid. Thank you all for your input. |
So some notes about this:
The new datatype introduced
java_specialised_generic_class_typet
will be further modified, as this is part of an active PR (#1576), so do not make blocking comments on its design if possible, as it's not final.The same applies for the concretisation process in
src/java_bytecode/generate_java_generic_type.cpp
. It is to be heavily revamped very soon.The whole point of this PR is to allow an urgent fix to be applied to CBMC so that tests for generics can be generated without hitting invariant violations because of some spurious goto statements in the goto program.
For more information about the nature of the bug that this fixes, feel free to contact me directly, or @smowton or @antlechner.
This needs an urgent review from @peterschrammel