Skip to content

Rounding intrinsics are not working #1025

Closed

Description

@adpaco

Calling rounding intrinsics (and likely other math intrinsics) results in an "assertion false". For example, the following code:

fn main() {
    let x: f32 = kani::any();
    let x_ceil = unsafe { std::intrinsics::ceilf32(x) };
}

returns this:

RESULTS:
Check 1: ceilf.assertion.1
         - Status: FAILURE
         - Description: "assertion false"
         - Location: <builtin-library-ceilf> in function ceilf

Check 2: <T as kani::Arbitrary>::any.assertion.1
         - Status: SUCCESS
         - Description: "resume instruction"
         - Location: ~/kani/library/kani/src/arbitrary.rs:17:5 in function <T as kani::Arbitrary>::any


SUMMARY: 
 ** 1 of 2 failed
Failed Checks: assertion false

VERIFICATION:- FAILED

It's still not clear what intrinsics are affected, but at least rounding intrinsics (ceil, floor, round) are not working. This is probably due because the irep expressions we generate for them are not exposed in CBMC, or because they are not the right ones.

Activity

  1. added
    [C] Bug
    on Apr 8, 2022
  2. self-assigned this
    on Apr 8, 2022
  3. tautschnig commented on Apr 8, 2022

    @tautschnig
    Member

    The problem appears to be in how goto-instrument invokes the C parser vs cbmc as I'm seeing the following error when running the individual steps:

    Reading GOTO program from 'ceil.out.for-main'
    Adding CPROVER library (x86_64)
    file /usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h line 21: syntax error before '__value'
    Writing GOTO program to 'ceil.out.for-main.with-library'
    

    I'll try to figure out what is going on here.

  4. tautschnig commented on Apr 8, 2022

    @tautschnig
    Member

    diffblue/cbmc#6789 fixes the problem.

  5. tautschnig commented on May 17, 2022

    @tautschnig
    Member

    The CBMC PR is now merged, and will be part of the next release (due 2022-05-26).

  6. adpaco commented on Jun 2, 2022

    @adpaco
    ContributorAuthor

    @tautschnig can you check the "fixme" test case in #1248 ? fmaxf continues to behave as if it was missing, but fmax and fminf for example aren't. I've checked and we don't do anything different for fmaxf, so my guess is that CBMC is failing to pick it up for some reason.

  7. tautschnig commented on Jun 3, 2022

    @tautschnig
    Member

    @adpaco-aws With apologies for this weird bug: diffblue/cbmc#6904 now fixes the issue.

  8. adpaco commented on Jun 3, 2022

    @adpaco
    ContributorAuthor

    Thanks, @tautschnig !

  9. moved this to In Progress in Kani v0.4on Jun 7, 2022
  10. Repository owner moved this from In Progress to Done in Kani v0.4on Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[C] Bug

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions