Skip to content

Fix casts in overflow checking function #2024

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 1 commit into from
Mar 24, 2023

Conversation

CaelmBleidd
Copy link
Member

@CaelmBleidd CaelmBleidd commented Mar 23, 2023

Fix the wrong way to cast primitive values in the function related to overflowing checks

Description

Added an explicit cast for arguments of the check function. They were wrapped into a primitive value that didn't change their symbolic type. That led to an error where we process primitive values of different sorts.

Fixes #2022

How to test

Automated tests

org.utbot.examples.math.OverflowAsErrorTest#testByteWithIntOverflow

Manual tests

I tested the example from the issue and a similar one. Note that an example from the issue doesn't contain overflow since + casts both operands to an int type, therefore, since the second one is a constant and the first one is a byte value, an integer overflow can never occur. If we transform the second value into a symbolic value, we'll find an overflow error.

image

Self-check list

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@CaelmBleidd CaelmBleidd added comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug-fix PR is fixing a bug labels Mar 23, 2023
@CaelmBleidd CaelmBleidd requested a review from Markoutte March 23, 2023 13:28
Copy link
Collaborator

@Markoutte Markoutte 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 we need discuss more about this feature, because, it can have strange behavior from user point of view. For example, we have this test be reported as it has overflow, but in real life it does not:

    public static int foo(byte a, short b) {
        return a + b;
    }

Despite this, I think this fix should be merged as is, because it fixes critical problem.

@CaelmBleidd CaelmBleidd merged commit d796369 into main Mar 24, 2023
@CaelmBleidd CaelmBleidd deleted the caelmbleidd/overflow_jvm_crash branch March 24, 2023 07:58
@CaelmBleidd
Copy link
Member Author

I think we need discuss more about this feature, because, it can have strange behavior from user point of view

Agree, created an issue for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug-fix PR is fixing a bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Test generation is cancelled due to JVM crash when overflow detection is on
2 participants