hakonhagland / perl-math-gsl

Building Math::GSL with GitHub Actions
1 stars 2 forks source link

Failing tests in i586 and aarch64 in version 0.45 #22

Closed perlpunk closed 2 weeks ago

perlpunk commented 1 month ago

I wanted to create a ticket in RT but I got a 403 Forbidden, so I hope it's ok to put it here.

We see failing tests in openSUSE: https://build.opensuse.org/package/live_build_log/devel:languages:perl:autoupdate/perl-Math-GSL/standard/i586

[   61s] + ./Build test
[   61s] Processing 2.8 XS files, GSL 2.8 (via gsl-config) at /usr
[   61s] Compiler        = cc (SUSE Linux) 13.3.0
[   61s] Copyright (C) 2023 Free Software Foundation, Inc.
[   61s] This is free software; see the source for copying conditions.  There is NO
[   61s] warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[   61s] 
[   61s] 
[   61s] ccflags         = -fPIC -I/usr/include -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wno-sometimes-uninitialized -Wno-unused-function -Wno-unused-value -Wno-unused-function -Wno-unused-variable -Wno-gnu -g -I/usr/include
[   61s] ldflags         = -shared -L/usr/lib -lgsl -lgslcblas -lm
[   61s] PERL5LIB        = 
[   61s] LD_LIBRARY_PATH = 
[   61s] # Testing Math::GSL 0.45 with GSL 2.8 on i586-linux-thread-multi-64int, Perl (/usr/bin/perl) 5.040000
[   61s] t/00-load.t ........ ok
[   61s] t/BLAS.t ........... ok
[   61s] t/BSpline.t ........ ok
[   61s] t/CBLAS.t .......... ok
[   62s] t/CDF.t ............ ok
[   62s] t/Chebyshev.t ...... ok
[   62s] t/Combination.t .... ok
[   62s] t/Complex.t ........ ok
[   62s] t/Const.t .......... ok
[   62s] t/DHT.t ............ ok
[   62s] t/Deriv.t .......... ok
[   62s] t/Diff.t ........... ok
[   62s] t/Eigen.t .......... ok
[   62s] t/Errno.t .......... ok
[   63s] t/FFT.t ............ ok
[   63s] t/Fit.t ............ ok
[   63s] # 
[   63s] #  Elements start differing at index 2, delta = 0.00099999999999989
[   63s] #      $x->[2] = 3
[   63s] #      $y->[2] = 3.001
[   63s] # 
[   63s] #  Elements start differing at index 2, delta = 9.99999998363421e-08
[   63s] #      $x->[2] = 3.0010001
[   63s] #      $y->[2] = 3.0010002
[   63s] t/GSL.t ............ ok
[   63s] t/Heapsort.t ....... ok
[   63s] t/Histogram.t ...... ok
[   63s] t/Histogram2D.t .... ok
[   63s] t/IEEEUtils.t ...... ok
[   63s] t/Integration.t .... ok
[   63s] t/Interp.t ......... ok
[   63s] 
[   63s] #   Failed test 'GSL LINALG LU DECOMP'
[   63s] #   at t/Linalg.t line 64.
[   63s] #   (in Math::GSL::Linalg::Test->GSL_LINALG_LU_DECOMP)
[   63s] #     Structures begin differing at:
[   63s] #          $got->[0] = '0'
[   63s] #     $expected->[0] = '4'
[   63s] # Looks like you failed 1 test of 71.
[   63s] t/Linalg.t ......... 
[   63s] Dubious, test returned 1 (wstat 256, 0x100)
[   63s] Failed 1/71 subtests 
[   64s] t/Machine.t ........ ok
[   64s] # 
[   64s] #  Elements start differing at index 1, delta = 1
[   64s] #      $x->[1] = 3
[   64s] #      $y->[1] = 2
[   64s] t/Matrix.t ......... ok
[   64s] # 
[   64s] #  Elements start differing at index 1, delta = 1
[   64s] #      $x->[1] = 3
[   64s] #      $y->[1] = 4
[   64s] # 
[   64s] #  Elements start differing at index 1, delta = 1
[   64s] #      $x->[1] = 3
[   64s] #      $y->[1] = 2
[   64s] t/MatrixComplex.t .. ok
[   64s] t/Min.t ............ ok
[   64s] t/Monte.t .......... ok
[   64s] t/Multifit.t ....... ok
[   64s] t/Multilarge.t ..... ok
[   64s] t/Multimin.t ....... ok
[   64s] t/Multiroots.t ..... ok
[   65s] t/Multiset.t ....... ok
[   65s] This is the end at t/NTuple.t line 14.
[   65s] t/NTuple.t ......... ok
[   65s] t/ODEIV.t .......... ok
[   65s] t/ODEIV_evolve.t ... ok
[   65s] t/Permutation.t .... ok
[   65s] t/Poly.t ........... ok
[   65s] t/PowInt.t ......... ok
[   65s] t/QRNG.t ........... ok
[   65s] t/RNG.t ............ ok
[   65s] t/Randist.t ........ ok
[   65s] t/Roots.t .......... ok
[   66s] t/Rstat.t .......... ok
[   66s] # GSL version=2.8
[   66s] t/SF.t ............. ok
[   66s] t/Siman.t .......... ok
[   66s] t/Sort.t ........... ok
[   66s] t/SparseMatrix.t ... ok
[   66s] t/Spline.t ......... ok
[   66s] t/Statistics.t ..... ok
[   67s] t/Sum.t ............ ok
[   67s] t/Sys.t ............ ok
[   67s] # 
[   67s] #  Elements start differing at index 0, delta = 9
[   67s] #      $x->[0] = 1
[   67s] #      $y->[0] = 10
[   67s] # 
[   67s] #  Elements start differing at index 0, delta = 9
[   67s] #      $x->[0] = 1
[   67s] #      $y->[0] = 10
[   67s] t/Vector.t ......... ok
[   67s] t/VectorComplex.t .. ok
[   67s] t/Wavelet.t ........ ok
[   67s] t/Wavelet2D.t ...... ok
[   67s] # Testing Math::GSL with GSL 1.16.1 on i586-linux-thread-multi-64int, Perl (/usr/bin/perl) 5.040000
[   67s] t/ver2func.t ....... ok
[   67s] 
[   67s] Test Summary Report
[   67s] -------------------
[   67s] t/Linalg.t       (Wstat: 256 (exited 1) Tests: 71 Failed: 1)
[   67s]   Failed test:  32
[   67s]   Non-zero exit status: 1
[   67s] t/Vector.t       (Wstat: 0 Tests: 143 Failed: 0)
[   67s]   TODO passed:   143
[   67s] Files=58, Tests=4193,  6 wallclock secs ( 0.32 usr  0.02 sys +  5.66 cusr  0.42 csys =  6.42 CPU)
[   67s] Result: FAIL
[   67s] Failed 1/58 test programs. 1/4193 subtests failed.
[   67s] error: Bad exit status from /var/tmp/rpm-tmp.YZpQGL (%check)
[   67s] 
[   67s] RPM build errors:
[   67s]     Bad exit status from /var/tmp/rpm-tmp.YZpQGL (%check)
[   67s] ### VM INTERACTION START ###
[   67s] [   64.064901][    T1] sysrq: Power Off
[   67s] [   64.065495][    T8] reboot: Power down
[   67s] ### VM INTERACTION END ###
[   67s] 
[   67s] i04-ch2d failed "build perl-Math-GSL.spec" at Thu Jul  4 19:17:55 UTC 2024.
[   67s] 

https://build.opensuse.org/package/live_build_log/devel:languages:perl:autoupdate/perl-Math-GSL/standard/aarch64

[   97s] + ./Build test
[   97s] Processing 2.8 XS files, GSL 2.8 (via gsl-config) at /usr
[   97s] Compiler        = cc (SUSE Linux) 13.3.0
[   97s] Copyright (C) 2023 Free Software Foundation, Inc.
[   97s] This is free software; see the source for copying conditions.  There is NO
[   97s] warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[   97s] 
[   97s] 
[   97s] ccflags         = -fPIC -I/usr/include -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wno-sometimes-uninitialized -Wno-unused-function -Wno-unused-value -Wno-unused-function -Wno-unused-variable -Wno-gnu -g -I/usr/include
[   97s] ldflags         = -shared -L/usr/lib64 -lgsl -lgslcblas -lm
[   97s] PERL5LIB        = 
[   97s] LD_LIBRARY_PATH = 
[   97s] 
[   97s] #   Failed test 'use Math::GSL::Matrix;'
[   97s] #   at t/00-load.t line 14.
[   97s] #     Tried to use 'Math::GSL::Matrix'.
[   97s] #     Error:  Can't load '/home/abuild/rpmbuild/BUILD/Math-GSL-0.45/blib/arch/auto/Math/GSL/Matrix/Matrix.so' for module Math::GSL::Matrix: /home/abuild/rpmbuild/BUILD/Math-GSL-0.45/blib/arch/auto/Math/GSL/Matrix/Matrix.so: undefined symbol: gsl_matrix_char_norm1 at /usr/lib/perl5/5.40.0/aarch64-linux-thread-multi/DynaLoader.pm line 206.
[   97s] #  at /home/abuild/rpmbuild/BUILD/Math-GSL-0.45/blib/lib/Math/GSL/Matrix.pm line 11.
[   97s] # Compilation failed in require at t/00-load.t line 14.
[   97s] # BEGIN failed--compilation aborted at t/00-load.t line 14.
...
hakonhagland commented 1 month ago

[ 63s] # Failed test 'GSL LINALG LU DECOMP' [ 63s] # at t/Linalg.t line 64. [ 63s] # (in Math::GSL::Linalg::Test->GSL_LINALG_LU_DECOMP) [ 63s] # Structures begin differing at: [ 63s] # $got->[0] = '0' [ 63s] # $expected->[0] = '4'

@perlpunk Thanks for the report! Yes it is better to submit issues here than in RT. I think this is due to changed behavior in GSL 2.8. From this version on, gsl_linalg_complex_LU_decomp() will return an integer > 0 if the matrix is singular, see: https://www.gnu.org/software/gsl/doc/html/linalg.html. For some reason the matrix in the test is not considered singular (which it is) or it is using a version of GSL < 2.8.

hakonhagland commented 1 month ago

@perlpunk Would it be possible to extend the github action test cases with i586 and aarch64? Or reproduce the error in a docker container?

hakonhagland commented 1 month ago

[ 63s] # $expected->[0] = '4'

Btw. the same behavior was observed on macOS, and I just did a quick fix here: https://github.com/hakonhagland/perl-math-gsl/blob/48e0aba6fcca8e95402d5e312acb0c80dab695e1/t/Linalg.t#L59

It would be interesting to know more details about why this happens

perlpunk commented 1 month ago

@perlpunk Would it be possible to extend the github action test cases with i586 and aarch64? Or reproduce the error in a docker container?

I don't know. But it's possible to create a free account on https://build.opensuse.org/ and even use it as a CI: See https://perlpunk.github.io/posts/2024-04-obs-as-a-ci-for-perl-modules/ and the previous article.

hakonhagland commented 1 month ago

Thanks, I will have a look at that when I come back from holiday. Probably end of next week :)

hakonhagland commented 1 month ago

@perlpunk I did some more experiments on macOS, and it seems that the failure there is due to round off errors causing the matrix to be almost singular but not quite. I pushed a new commit to fix the issue here: https://github.com/hakonhagland/perl-math-gsl/commit/98b00b879b0e10202e6ebb4442d8ae5091b73858

Can you try it on aarch64? Hopefully it will fix this issue.

perlpunk commented 1 month ago

ok, I'll run it tomorrow :)

hakonhagland commented 1 month ago

@perlpunk Thanks! Looking at the error messages from i586 and aarch64 again now, I missed that they do not report the same error. The error for aarch64 is different:

[   97s] #     Error:  Can't load '/home/abuild/rpmbuild/BUILD/Math-GSL-0.45/blib/arch/auto/Math/GSL/Matrix/Matrix.so' 
for module Math::GSL::Matrix: /home/abuild/rpmbuild/BUILD/Math-GSL-0.45/blib/arch/auto/Math/GSL/Matrix/Matrix.so: 
undefined symbol: gsl_matrix_char_norm1 at /usr/lib/perl5/5.40.0/aarch64-linux-thread-multi/DynaLoader.pm line 206.

I will try to reproduce this error tomorrow.

perlpunk commented 1 month ago

ok, i586 succeeded with the patch at least :) I attached the log: Math-GSL-i586.log

hakonhagland commented 1 month ago

@perlpunk Thanks for the update! Seems like the issue on aarch64 is due to gsl_matrix_char_norm1() is not defined in the generated libgsl.so due to this macro https://git.savannah.gnu.org/cgit/gsl.git/tree/matrix/prop_source.c#n163

I will investigate this a little bit more to decide what to do.

hakonhagland commented 1 month ago

undefined symbol: gsl_matrix_char_norm1

@perlpunk Yes, it seems that the failure on aarch64 was due to char being treated as unsigned on that platform. I have added some commits to master branch to address this, see e.g.

https://github.com/hakonhagland/perl-math-gsl/blob/620cb5926a87063d33bdd658dbbc18ff2054327d/inc/Ver2Func.pm#L582

Can you check if the current master branch solves the reported test failure on aarch64? Thanks!

gregoa commented 3 weeks ago

We've seen the same test failures in t/Linalg.t in Debian:

After applying (parts of) the aforementioned commit 98b00b8 on top of 0.45 (+ 8be5b93), it looks like it builds everywhere (one architecture is still missing):

As @mohawk2 mentioned in #36, maybe this would be a good time to upload a new release to the CPAN?

Cheers, gregor, Debian Perl Group

hakonhagland commented 3 weeks ago

@gregoa Thanks for the feedback! I have uploaded version 0.48 to CPAN now: https://metacpan.org/pod/Math::GSL

gregoa commented 3 weeks ago

On Fri, 26 Jul 2024 23:52:51 -0700, Håkon Hægland wrote:

@gregoa Thanks for the feedback! I have uploaded version 0.48 to CPAN now: https://metacpan.org/pod/Math::GSL

Thank you!

-- .''. https://info.comodo.priv.at -- Debian Developer https://www.debian.org : :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D 85FA BB3A 6801 8649 AA06 . ' Member VIBE!AT & SPI Inc. -- Supporter Free Software Foundation Europe -

perlpunk commented 2 weeks ago

Sorry for not being able to test, I was busy. Now I have the problem that I have to package the new dependency Math::GSL::Alien, and I'm not so familiar with packaging alien modules, so I can't test it yet. But @gregoa confirmed that it works, so thank you!

perlpunk commented 2 weeks ago

btw, the issue tracker on cpan still points to https://rt.cpan.org/Public/Dist/Display.html?Name=Math-GSL You can influence that with a setting in META.yaml/json.

perlpunk commented 2 weeks ago

Oh, and this is still looking weird and missing the last 4 versions: https://metacpan.org/dist/Math-GSL/view/Changes But that's probably a bug in the metacpan pod parser...

hakonhagland commented 2 weeks ago

But that's probably a bug in the metacpan pod parser...

@perlpunk I think it might be missing some newlines around the Pod directives, see #38. Thanks for reporting!

hakonhagland commented 2 weeks ago

You can influence that with a setting in META.yaml/json.

@perlpunk The module is not using META.json I guess since it is using Module::Build instead of ExtUtils::MakeMaker ? I am trying to figure out how set the bug tracker URL for Module::Build

hakonhagland commented 2 weeks ago

I have to package the new dependency Math::GSL::Alien, and I'm not so familiar with packaging alien modules

@perlpunk It should be similar to packaging Alien::GSL (which it used before version 0.48) ?

perlpunk commented 2 weeks ago

You can influence that with a setting in META.yaml/json.

@perlpunk The module is not using META.json I guess since it is using Module::Build instead of ExtUtils::MakeMaker ? I am trying to figure out how set the bug tracker URL for Module::Build

I couldn't find a complete example, but those links in combination should do it: https://metacpan.org/dist/Module-Build/view/lib/Module/Build/API.pod#meta_merge https://blogs.perl.org/users/neilb/2017/05/specifying-dependencies-for-your-cpan-distribution.html https://metacpan.org/pod/CPAN::Meta::Spec#resources

Your module does package a https://metacpan.org/release/HAKONH/Math-GSL-0.48/source/META.json and META.yaml Actually, you already have a meta_merge, so you just need to add the bugtracker: https://metacpan.org/release/HAKONH/Math-GSL-0.48/source/Build.PL#L128

hakonhagland commented 2 weeks ago

Actually, you already have a meta_merge, so you just need to add the bugtracker

@perlpunk Thanks! Added this using meta_merge in #39

perlpunk commented 2 weeks ago

I have to package the new dependency Math::GSL::Alien, and I'm not so familiar with packaging alien modules

@perlpunk It should be similar to packaging Alien::GSL (which it used before version 0.48) ?

Unfortunately not. I added gsl-devel to the build requirements, but it still wants to fetch the gsl library from the intenet, which we don't allow in the build environment, So I need an existing library I can depend on. But I guess that's off topic for this issue. I might get help from colleagues how to do that.

hakonhagland commented 2 weeks ago

It should be similar to packaging Alien::GSL... Unfortunately not.

@perlpunk It should not download GSL from the internet if it can find it on your system. In which directory on your system do you have libgsl.so installed ?

perlpunk commented 2 weeks ago
% rpm -ql gsl-devel-2.8-2.1.x86_64 | grep libgsl.so
/usr/lib64/libgsl.so

This is the spec file for Alien-GSL: https://build.opensuse.org/projects/devel:languages:perl/packages/perl-Alien-GSL/files/perl-Alien-GSL.spec?expand=1 So the only change we make is adding BuildRequires: gsl-devel

My experiment with Math-GSL-Alien is here: https://build.opensuse.org/package/show/home:tinita:branches:devel:languages:perl:CPAN-x/perl-Math-GSL-Alien

perlpunk commented 2 weeks ago

Hm, I actually made a mistake. Now that I added gsl-devel to perl-Math-GSL-Alien I get a different error: https://build.opensuse.org/package/live_build_log/home:tinita:branches:devel:languages:perl:CPAN-x/perl-Math-GSL-Alien/openSUSE_Tumbleweed/x86_64

[    7s] rmdir: failed to remove '/home/abuild/rpmbuild/BUILDROOT/perl-Math-GSL-Alien-1.50.0-6.1.x86_64/usr/lib/perl5/vendor_perl/5.40.0/x86_64-linux-thread-multi/auto/Math/GSL/Alien': Directory not empty
[    7s] rmdir: failed to remove '/home/abuild/rpmbuild/BUILDROOT/perl-Math-GSL-Alien-1.50.0-6.1.x86_64/usr/lib/perl5/vendor_perl/5.40.0/x86_64-linux-thread-multi/auto/Math/GSL': Directory not empty
...
hakonhagland commented 2 weeks ago

@perlpunk I created a new release for the last two PRs, see: https://github.com/hakonhagland/perl-math-gsl/releases/tag/v0.49. Let me know if I should upload this to CPAN or if that would mess up your current packaging work..

perlpunk commented 2 weeks ago

Sure, go ahead!

hakonhagland commented 2 weeks ago

In which directory on your system do you have libgsl.so installed ? ... /usr/lib64/libgsl.so

@perlpunk Thanks for the info. Then, there should also be a script gsl-config usually installed in a bin directory. Try to add that bin directory to the PATH environment variable. See:

https://github.com/hakonhagland/perl-math-gsl/blob/48c7044b57b31c5826658b2b37b9e990c78b23ae/Build.PL#L424

hakonhagland commented 2 weeks ago

@perlpunk You may need to set the PKG_CONFIG_PATH environment variable to avoid Math::GSL::Alien starting the download from the internet. For example if I have installed GSL in /opt/gsl/gsl-2.8, then I would do:

$ export PKG_CONFIG_PATH=/opt/gsl/gsl-2.8/lib/pkgconfig

Let me know if this helps.