weidai11 / cryptopp

free C++ class library of cryptographic schemes
https://cryptopp.com
Other
4.67k stars 1.47k forks source link

8.7.0 fail test on Fedora Rawhide s390x #1193

Closed Vascom closed 9 months ago

Vascom commented 1 year ago

Can you help debug problem with failed test after build 8.7.0 on Fedora Rawhide? Build is OK but one test fail and only on s390x architecture.

ed25519 validation suite running...
passed    signature key validation
FAILED    signature and verification
passed    checking invalid signature
FAILED    verification check against test vector

Full build log https://kojipkgs.fedoraproject.org//work/tasks/4369/97754369/build.log Packages used for build https://kojipkgs.fedoraproject.org//work/tasks/4369/97754369/root.log Builds for other arches https://koji.fedoraproject.org/koji/taskinfo?taskID=97754270

noloader commented 1 year ago

Thanks @Vascom,

I have a Debian Chroot with s390x for testing on Debian, but I don't have anything for Fedora. See https://cryptopp.com/wiki/Debian_Chroot#S/390x .

How do I setup a Fedora testing environment for s390x on Fedora? Google is failing me.


We started seeing failures under GCC 12 because the compiler was mis-identifying live code as dead code (and was removing it). See Issue 1141 .

The workaround was to add -fno-devirtualize to CXXFLAGS. Could you give it a try until I can duplicate the problem? (The change is in master).

Vascom commented 1 year ago

To workaround gcc-12 issue we use clang for build. -fno-devirtualize to CXXFLAGS not helped https://kojipkgs.fedoraproject.org//work/tasks/5533/97795533/build.log

You can use mock cross-compile to build and test for s390 on Fedora. Besides ordinary mock you need to install qemu-user-static package and use this command:

mock -r fedora-rawhide-s390x --forcearch=s390x rebuild cryptopp-8.7.0-2.fc39.src.rpm

Also we can try to get access to s390x shell from Fedora s390x SIG https://fedoraproject.org/wiki/Architectures/s390x#Shell_access_for_debugging

But with qemu test segfaulted:

+ ./cryptest.exe v
Using seed: 1676961204      
Testing Settings...
passed:  Your machine is big endian.
passed:  Your machine is 64-bit.
passed:  sizeof(byte) == 1
passed:  sizeof(word16) == 2
passed:  sizeof(word32) == 4
passed:  sizeof(word64) == 8
passed:  sizeof(hword) == 2, sizeof(word) == 4, sizeof(dword) == 8
passed:  cacheLineSize == 32
Testing operating system provided blocking random number generator...
passed:  it took 0 seconds to generate 16 bytes
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
/var/tmp/rpm-tmp.HkUPLU: line 44:  8062 Segmentation fault      (core dumped) ./cryptest.exe v
noloader commented 1 year ago

Thanks @Vascom,

I did not notice Clang was used for Fedora. I thought Fedora was a GCC shop.

I tested under my Debian s390x chroot. Things tested Ok with Clang 14.0.6.

I need some time to setup a Fedora+mock test environment. I'll follow https://fedoraproject.org/wiki/Using_Mock_to_test_package_builds, unless you have a better HowTo.


Testing operating system provided blocking random number generator...
passed:  it took 0 seconds to generate 16 bytes
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
/var/tmp/rpm-tmp.HkUPLU: line 44:  8062 Segmentation fault      (core dumped) ./cryptest.exe v

That's an unusual place to catch a segfault. I look forward to digging into this one :)

The "blocking random number generator" is /dev/random. The tests that cause the fault appear to be around https://github.com/weidai11/cryptopp/blob/master/validat3.cpp#L586 :

word32 result = prng.GenerateWord32();
result = prng.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff));

prng.GenerateBlock(reinterpret_cast<byte*>(&result), 4);
prng.GenerateBlock(reinterpret_cast<byte*>(&result), 3);
prng.GenerateBlock(reinterpret_cast<byte*>(&result), 2);
prng.GenerateBlock(reinterpret_cast<byte*>(&result), 1);
prng.GenerateBlock(reinterpret_cast<byte*>(&result), 0);
Vascom commented 1 year ago

Fedora now use clang 15.0.7. Can you try it at Debian?

noloader commented 1 year ago

Fedora now use clang 15.0.7. Can you try it at Debian?

Yes, will do. I've got my Rawhide VM setup and Mock installed. I've got to go through the remainder of the document to setup the s390x environment.

noloader commented 1 year ago

@Vascom,

Crap, this fell off my radar. I'm still going to complete it. Need more time in the day...

Vascom commented 1 year ago

Seems this fixed in 8.8.0.

Vascom commented 1 year ago

Works fine at rawhide https://koji.fedoraproject.org/koji/buildinfo?buildID=2224355 but still failed at EPEL 9 https://koji.fedoraproject.org/koji/taskinfo?taskID=102776014