Skip to content

FPE in zrotg with g++-13 -O3 #4909

Closed
Closed

Description

@shardest

I have a simple test program that worked on Ubuntu 22.04 and now fails after upgrading to 24.04. I filed an Ubuntu bug report and then realized that I can reproduce the issue without using Ubuntu's OpenBLAS package but rather building from source. For reference, here's the bug report:

https://bugs.launchpad.net/ubuntu/+source/openblas/+bug/2083157

This is the test program (g++ -o test_blas test_blas.cpp -lopenblas):

#include
#include

#include <fenv.h>

typedef std::complex dcomp;

extern "C" {
void zrotg_(dcomp*, dcomp*, double*, dcomp*);
}

int main(void) {
feenableexcept(FE_INVALID |
FE_DIVBYZERO |
FE_OVERFLOW |
FE_UNDERFLOW);

dcomp ain(0.28048120941867205058,0.028460086243503417841), bin(0.018279187257355982571,0);
double c(0.0);
dcomp s(0.0);

dcomp a=ain, b=bin;
zrotg_(&a, &b, &c, &s);
std::cout << a << " " << b << " " << c << " " << s << std::endl;

return 0;

}

Expected output (get this with -O0):

(0.28107,0.101469) (0.0182792,0) 0.997905 (0.0643715,0.0065317)

Output with -O1, -O2, -O3:
Floating point exception (core dumped)

Output with -O3 but FPE turned off:
(0.28107,inf) (0.0182792,0) 0.997905 (0.0643715,0.0065317)

Additional notes:

  • Also fails with the Intel compiler and OpenBLAS
  • Works with the Intel compiler and MKL BLAS

Here are some results for different OpenBLAS versions:

  • 0.3.20 (version in Ubuntu 22.04, where my program used to work): works
  • 0.3.23: works
  • 0.3.24: fails
  • 0.3.26 (version in Ubuntu 24.04): fails

It seems this may be related to the implementation of "safe scaling" that went in for 0.3.24, possibly from #4130.

Activity

  1. martin-frbg commented on Sep 30, 2024

    @martin-frbg
    Collaborator

    What architecture/cpu do you see this with ?

  2. shardest commented on Sep 30, 2024

    @shardest
    Author

    My system is a dual Xeon e5-2630v4.

  3. martin-frbg commented on Sep 30, 2024

    @martin-frbg
    Collaborator

    So a fairly common Haswell-generation x86_64... I cannot reproduce this with the current 0.3.28 and gcc 13.2 or 14.2 here

  4. shardest commented on Sep 30, 2024

    @shardest
    Author

    I can try with 0.3.28 but I won't have time to get to it until this evening. Did you try with 0.3.26?

  5. martin-frbg commented on Sep 30, 2024

    @martin-frbg
    Collaborator

    This (a typo leading to uninitialized data being used as denominator) was fixed in the context of #4499 (released as 0.3.27)

  6. shardest commented on Sep 30, 2024

    @shardest
    Author

    Thanks - I confirmed that it works on my system with 0.3.27. I will mention it on the Ubuntu bug report.

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