Skip to content

FPU Exception when calling AssertEquals_REAL #279

Description

@TobiasKnauss

Describe the bug
'Port_851' (851): Exception (Exception Code: 0xc0000090, FPU invalid operation) in PLC Application PLC1 Instance, Task PlcTask (RBP: 0xe464a0f010, RIP: 0x2d6b9e6d621, RSP: 0xe464a0ebe0), Area 1, Offset 0x33301

In FB_AssertResultStatic.ReportResult, the data from previous assertions is compared to the current one. In this comparison in F_IsAnyEqualToUnionValue, a byte sequence of an expected or actual value of a previous test may be interpreted falsely as NaN when executing an assertion with REAL or LREAL. A NaN check is missing.

Additionally, the type of the expected/actual value should be stored in the ST_AssertResult to circumvent useless comparisons, because otherwise, values could falsely be interpreted as already existing although being of different type. This would already solve my issue, but not remove the bug. Therefore, 2 fixes are required.

Furthermore, AND_THEN should be used in the IF condition for performance increase.

To Reproduce
Execute a DINT assertion with expected -7777777, which is 0xFF89520F, which represents NaN in 32bit IEEE754.
Execute a REAL assertion afterwards. It will raise the exception.

Expected behavior
No exception.

Software versions
TcUnit library: 1.3.1. with unmerged changes.
XAE: 3.1.4026.18

Run environment
Usermode Runtime 3.1.4026.18

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions