Package: mlucas
Version: 20.1.1-1
Severity: serious
Tags: patch
User: [email protected]
Usertags: origin-ubuntu kinetic ubuntu-patch
Hi Alex,
The new version of mlucas in unstable is failing to build on arm*
architectures where it previously built, because upstream has introduced
some wrong architecture-specific cpu-checking code:
[...]
make check-TESTS
make[2]: Entering directory '/<<PKGBUILDDIR>>'
Mlucas 20.1.1
http://www.mersenneforum.org/mayer/README.html
System total RAM = 11954, free RAM = 8417
ERROR: at line 1913 of file upstream/src/util.c
Assertion failed: /proc/cpuinfo file not found!
[...]
(https://buildd.debian.org/status/fetch.php?pkg=mlucas&arch=arm64&ver=20.1.1-1&stamp=1641070740&raw=0)
The problem is that upstream/src/util.c is calling mlucas_fopen(), which
mangles the argument to prefix it with $HOME/.mlucas.d/.
So first of all, '$HOME' should never appear in the argument to the openat()
syscall; this fopen wrapper function is failing to do variable interpolation
for the home directory.
And secondly, /proc/cpuinfo should never be relative to the mlucas directory
- this is a system path.
I've uploaded the attached patch to Ubuntu, fixing the build regression
there. Please consider including in Debian as well.
Thanks,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer https://www.debian.org/
[email protected] [email protected]
diff -Nru mlucas-20.1.1/debian/patches/fopen-on-arm.patch
mlucas-20.1.1/debian/patches/fopen-on-arm.patch
--- mlucas-20.1.1/debian/patches/fopen-on-arm.patch 1969-12-31
16:00:00.000000000 -0800
+++ mlucas-20.1.1/debian/patches/fopen-on-arm.patch 2022-07-07
09:40:44.000000000 -0700
@@ -0,0 +1,22 @@
+Description: don't use mlucas_fopen() for system files
+ mlucas_fopen() is a wrapper around fopen() that rewrites the path in
+ various cases. It is not an appropriate interface for opening system
+ files like /proc/cpuinfo, and causes the mlucas binary to be completely
+ broken on ARM architectures.
+Author: Steve Langasek <[email protected]>
+Forwarded: no
+Last-Update: 2022-07-07
+
+Index: mlucas-20.1.1/upstream/src/util.c
+===================================================================
+--- mlucas-20.1.1.orig/upstream/src/util.c
++++ mlucas-20.1.1/upstream/src/util.c
+@@ -1909,7 +1909,7 @@
+ int has_asimd(void)
+ {
+ char in_line[STR_MAX_LEN];
+- FILE*fp = mlucas_fopen("/proc/cpuinfo", "r");
++ FILE*fp = fopen("/proc/cpuinfo", "r");
+ ASSERT(HERE, fp != 0x0, "/proc/cpuinfo file not found!");
+ while(fgets(in_line, STR_MAX_LEN, fp) != 0x0) {
+ if(strstr(in_line, "asimd") != 0)
diff -Nru mlucas-20.1.1/debian/patches/series
mlucas-20.1.1/debian/patches/series
--- mlucas-20.1.1/debian/patches/series 1969-12-31 16:00:00.000000000 -0800
+++ mlucas-20.1.1/debian/patches/series 2022-07-07 09:39:00.000000000 -0700
@@ -0,0 +1 @@
+fopen-on-arm.patch