Skip to content
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

Improve the value domain to keep track of integer sets #129

Open
arthaud opened this issue Jul 9, 2019 · 1 comment
Open

Improve the value domain to keep track of integer sets #129

arthaud opened this issue Jul 9, 2019 · 1 comment
Labels
C-false-positive Category: False Positive C-feature-request Category: Feature Request L-c Language: C P-medium Priority: Medium

Comments

@arthaud
Copy link
Member

arthaud commented Jul 9, 2019

On the following code:

int main() {
    const int indexes[5] = {2, 0, 4, 1, 3};
    int array[5];

    for (int i = 0; i < 5; i++) {
        int index = indexes[i];
        array[index] = index;
    }

    return 0;
}

IKOS produces the following warning:

test.c:7:22: warning: possible buffer overflow, could not bound index for access of local variable 'array' of 5 elements
        array[index] = index;
                     ^

To remove this warning, the analysis needs to bound all the integers stored in the indexes array. It could infer that indexes[i] is in [0, 4] and prove that the array access is safe.

@arthaud arthaud added C-false-positive Category: False Positive L-c Language: C P-medium Priority: Medium C-feature-request Category: Feature Request labels Jul 9, 2019
@arthaud
Copy link
Member Author

arthaud commented Jul 10, 2019

This could be implemented in the memory domain by adding a map from memory locations to a value set abstraction.

This is already implemented for pointers with the _pointer_sets map.

This false positive appears in our benchmarks:

  • 2 times in aeroquad
  • 5 times in gen2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-false-positive Category: False Positive C-feature-request Category: Feature Request L-c Language: C P-medium Priority: Medium
Projects
None yet
Development

No branches or pull requests

1 participant