[med-svn] [Git][med-team/libmaus2][master] 4 commits: Fix undefined PosixFunctions::fstatSizeAndMode on 32 bit architectures
Andreas Tille (@tille)
gitlab at salsa.debian.org
Sun Nov 1 18:58:24 GMT 2026
Andreas Tille pushed to branch master at Debian Med / libmaus2
Commits:
0ffad012 by Andreas Tille at 2026-10-31T07:01:15+01:00
Fix undefined PosixFunctions::fstatSizeAndMode on 32 bit architectures
AC_SYS_LARGEFILE records the option enabling large file support in
ac_cv_sys_largefile_opts, but it does not add it to CPPFLAGS. configure
stores the initial CPPFLAGS in LIBMAUSCPPFLAGS early, and the targets
libmaus2_posix, libmaus2_arch, libmaus2_autoarray, libmaus2_parallel,
libmaus2_stacktrace, libmaus2_demangle and libmaus2_exception are built
with their own *_CPPFLAGS, which expand @LIBMAUSCPPFLAGS@ instead of
$(CPPFLAGS). Hence off_t was 32 bit for the definition of
PosixFunctions::fstatSizeAndMode() and 64 bit for its callers, and linking
libmaus2.so failed with an undefined reference to the 64 bit variant.
Add the option to LIBMAUSCPPFLAGS, which is expanded by all targets and
exported via libmaus2.pc, so that every translation unit agrees on off_t.
Closes: #1091568
- - - - -
43026fea by Andreas Tille at 2026-10-31T07:01:40+01:00
Fix cache line size detection on architectures without sysfs cache info
add-support-for-loong64.patch replaced sysconf(_SC_LEVEL1_DCACHE_LINESIZE)
by reading /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size on
Linux. That file is not present in every environment, and the value was
read using a %d conversion into a uint64_t, so the function returns 0
whenever the file cannot be read (or produces a bogus number otherwise).
AutoArrayAllocate<N,alloc_type_memalign_cacheline> then passes that value
as std::align_val_t to operator new, and an alignment of 0 makes the
allocation throw std::bad_alloc, which surfaced as
AutoArray<unsigned long,alloc_type_memalign_cacheline> failed to allocate
1398102 elements (11184816 bytes)
in testRank.sh and testdnarank.sh on arm64, armhf, s390x, hppa, powerpc,
ppc64, sparc64 and alpha.
Read the file with the SCNu64 conversion, verify that the result is a non
zero power of two and fall back to sysconf(_SC_LEVEL1_DCACHE_LINESIZE) and
then to alignof(std::max_align_t), so that the value is always usable as
an alignment.
Closes: #1069691, #1091144
- - - - -
ee9d6bd9 by Andreas Tille at 2026-10-31T07:01:48+01:00
Do not enable autoarray tracing on arm64 any more
The --enable-autoarraytrace option was added for arm64 in 2.0.813+ds-4 to
trace the testRank.sh and testdnarank.sh failures. Those are fixed by
cacheline-size-fallback.patch now, and with gcc-16 the option breaks the
build, because AutoArrayBackTrace<7> holds std::atomic members and
AutoArray's constructor pushes it into a std::vector, which instantiates
the deleted std::atomic copy constructor:
libmaus2/autoarray/AutoArray.hpp:524: required from here
libmaus2/autoarray/AutoArray.hpp:863: required from here
Drop the override, so that all architectures build with the default
configuration.
Part of #1091144: the arm64 build additionally needed this change
once cacheline-size-fallback.patch made the tests pass again.
- - - - -
1910321f by Andreas Tille at 2026-10-31T07:01:57+01:00
Close #934619, whose compile errors no longer occur
The 32 bit build failures reported in #934619 were
"no matching function for call to BlockMergeControl::sam_allocate_encoder()
/ cram_allocate_encoder()" when compiling test/testparallelbamblocksort.cpp.
That file builds without any such diagnostic now (checked in the i386 build
log for 2.0.813+ds-6), and the 32 bit architectures m68k, sh4 and x32 built
this version successfully, so the bug was fixed upstream.
Closes: #934619
- - - - -
5 changed files:
- debian/changelog
- + debian/patches/cacheline-size-fallback.patch
- + debian/patches/largefile-cppflags.patch
- debian/patches/series
- debian/rules
Changes:
=====================================
debian/changelog
=====================================
@@ -2,6 +2,28 @@ libmaus2 (2.0.813+ds-7) UNRELEASED; urgency=medium
* Drop redundant fields from watch file
* Reflow Uploaders field (cme)
+ * largefile-cppflags.patch: new: add the large file flag found by
+ AC_SYS_LARGEFILE to LIBMAUSCPPFLAGS. Targets using their own
+ *_CPPFLAGS did not see it, so off_t had a different size there and
+ PosixFunctions::fstatSizeAndMode() was undefined when linking on 32 bit
+ architectures. (Closes: #1091568)
+ * cacheline-size-fallback.patch: new: fix the cache line size detection.
+ The sysfs file read by add-support-for-loong64.patch does not exist
+ everywhere and was parsed with the wrong conversion, so the cache line
+ size ended up as 0. The aligned allocation then threw std::bad_alloc
+ and made testRank.sh and testdnarank.sh fail on arm64 and other
+ architectures. Fall back to sysconf() and alignof(std::max_align_t).
+ (Closes: #1069691, #1091144)
+ * Do not enable autoarray tracing for arm64 any more. It was added in
+ 2.0.813+ds-4 to track down the failures above, but with gcc-16 it breaks
+ the build, as AutoArrayBackTrace holds std::atomic members and is put
+ into a std::vector, which requires them to be copyable.
+ * Note that the "no matching function for call to
+ BlockMergeControl::sam_allocate_encoder()" errors from #934619 no longer
+ occur: test/testparallelbamblocksort.cpp builds without any such
+ diagnostic on the 32 bit architectures, and m68k, sh4 and x32 build
+ this version successfully. The failure was fixed upstream.
+ (Closes: #934619)
-- Andreas Tille <tille at debian.org> Fri, 30 Oct 2026 17:33:47 +0100
=====================================
debian/patches/cacheline-size-fallback.patch
=====================================
@@ -0,0 +1,92 @@
+Description: make the cache line size detection robust.
+ add-support-for-loong64.patch replaced the sysconf(_SC_LEVEL1_DCACHE_LINESIZE)
+ call by reading /sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size
+ on Linux. That file does not exist in every environment and the patch also
+ read it using a "%d" conversion into a uint64_t. Both cases leave the value
+ at 0 (or produce a bogus number), and the aligned allocation functions in
+ AutoArray.hpp then call operator new(size, std::align_val_t{0}), which throws
+ std::bad_alloc. On architectures using the generic glibc sysconf() (arm64,
+ armhf, s390x, hppa, powerpc, ppc64, sparc64, alpha), this made testRank.sh
+ and testdnarank.sh abort with
+ .
+ AutoArray<unsigned long,alloc_type_memalign_cacheline> failed to allocate
+ 1398102 elements (11184816 bytes)
+ .
+ The fix reads the file with the SCNu64 conversion, validates the result
+ (a non zero power of two), falls back to sysconf(_SC_LEVEL1_DCACHE_LINESIZE)
+ and finally to alignof(std::max_align_t), so that the value is always usable
+ as an alignment.
+Author: Andreas Tille <tille at debian.org>
+Bug-Debian: https://bugs.debian.org/1069691
+Bug-Debian: https://bugs.debian.org/1091144
+Forwarded: https://gitlab.com/german.tischler/libmaus2/-/issues/40
+Last-Update: 2026-10-30
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- libmaus2.orig/src/libmaus2/arch/CacheLineSize.cpp
++++ libmaus2/src/libmaus2/arch/CacheLineSize.cpp
+@@ -18,6 +18,8 @@
+ #include <libmaus2/arch/CacheLineSize.hpp>
+ #include <stdexcept>
+ #include <stdio.h>
++#include <cinttypes>
++#include <cstddef>
+
+ #include <libmaus2/LibMausConfig.hpp>
+
+@@ -47,9 +49,11 @@
+ fp = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r");
+ uint64_t i = 0;
+ if(fp){
+- fscanf(fp, "%d", &i);
++ if ( fscanf(fp, "%" SCNu64, &i) != 1 )
++ i = 0;
+ fclose(fp);
+ }
++
+ return i;
+ }
+ #elif defined(_WIN32)
+@@ -108,13 +112,41 @@
+ }
+ #endif
+
++/**
++ * check whether a cache line size can be used as an alignment value for
++ * the aligned allocation functions, i.e. it is a non zero power of two.
++ * Values of 0 or other invalid numbers make the allocation routines throw
++ * std::bad_alloc, so they have to be filtered out and replaced by a
++ * reliable default.
++ **/
++static bool validCacheLineSize(uint64_t const cachelinesize)
++{
++ return cachelinesize && ((cachelinesize & (cachelinesize-1)) == 0);
++}
++
+ std::size_t libmaus2::arch::CacheLineSize::getCacheLineSize()
+ {
+ std::lock_guard<std::mutex> slock(cachelinesizelock);
+
+ if ( ! cachelinesizeinitcomplete.load() )
+ {
+- cachelinesize.store(getCacheLineSizeLocal());
++ uint64_t lcachelinesize = getCacheLineSizeLocal();
++
++ // the sysfs file read on Linux is not available everywhere (e.g. in
++ // chroots or containers), so fall back to sysconf() in that case
++ #if defined(__linux__) && defined(LIBMAUS2_HAVE_SYSCONF) && defined(_SC_LEVEL1_DCACHE_LINESIZE)
++ if ( ! validCacheLineSize(lcachelinesize) )
++ {
++ long const sc = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
++ if ( sc > 0 )
++ lcachelinesize = sc;
++ }
++ #endif
++ // last resort: the alignment guaranteed by the allocation functions
++ if ( ! validCacheLineSize(lcachelinesize) )
++ lcachelinesize = alignof(std::max_align_t);
++
++ cachelinesize.store(lcachelinesize);
+ cachelinesizeinitcomplete.store(1);
+ }
+
=====================================
debian/patches/largefile-cppflags.patch
=====================================
@@ -0,0 +1,36 @@
+Description: make the large file flags found by AC_SYS_LARGEFILE apply to all
+ objects. AC_SYS_LARGEFILE only records the option it found in
+ ac_cv_sys_largefile_opts, it does not add it to CPPFLAGS. The library
+ however builds some of its objects (libmaus2_posix, libmaus2_arch,
+ libmaus2_autoarray, ...) using per-target *_CPPFLAGS, which expand
+ @LIBMAUSCPPFLAGS@ but not the global $(CPPFLAGS) that automake passes
+ anyway only for targets without their own flags. On 32 bit
+ architectures this made off_t and hence the mangled name of
+ PosixFunctions::fstatSizeAndMode() differ between the definition and
+ its callers, so linking libmaus2 failed with an undefined reference to
+ PosixFunctions::fstatSizeAndMode(int, long long&, unsigned char*).
+ Adding the option to LIBMAUSCPPFLAGS makes every target agree on off_t
+ and also exports the flag to users of libmaus2.pc.
+Author: Andreas Tille <tille at debian.org>
+Bug-Debian: https://bugs.debian.org/1091568
+Forwarded: no
+Last-Update: 2026-10-30
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- libmaus2.orig/configure.ac 2022-12-10 22:04:26.000000000 +0100
++++ libmaus2/configure.ac 2026-10-30 23:54:16.008000000 +0100
+@@ -3044,6 +3044,14 @@
+ fi
+
+ AC_SYS_LARGEFILE
++dnl AC_SYS_LARGEFILE only records the option it found in ac_cv_sys_largefile_opts;
++dnl add it to the exported flags, so that every target (including the ones using
++dnl per-target *_CPPFLAGS) sees the same off_t size
++case "${ac_cv_sys_largefile_opts}" in
++ -D*)
++ LIBMAUSCPPFLAGS="${LIBMAUSCPPFLAGS} ${ac_cv_sys_largefile_opts}"
++ ;;
++esac
+ LIBMAUS2_FILEOFFSET_BITS=
+ if test \( ! -z "${ac_cv_sys_file_offset_bits}" \) -a \( "${ac_cv_sys_file_offset_bits}" != "no" \) ; then
+ LIBMAUS2_FILEOFFSET_BITS="#define _FILE_OFFSET_BITS ${ac_cv_sys_file_offset_bits}"
=====================================
debian/patches/series
=====================================
@@ -1,3 +1,5 @@
add-support-for-loong64.patch
gcc-15.patch
unlock-stdc++.patch
+largefile-cppflags.patch
+cacheline-size-fallback.patch
=====================================
debian/rules
=====================================
@@ -15,14 +15,6 @@ export DEB_BUILD_MAINT_OPTIONS=hardening=+all
%:
dh $@
-# We go extra lengths to try to pinpoint test failures on arm64, but
-# autoarraytrace is also causing issues of its own on at least i386, so
-# it needs to be enabled only on the affected platform.
-ifeq ($(DEB_HOST_ARCH),arm64)
-override_dh_auto_configure:
- dh_auto_configure -- --enable-autoarraytrace
-endif
-
override_dh_install:
dh_install
# following override suggestion from suggestion of Andreas to Michael
View it on GitLab: https://salsa.debian.org/med-team/libmaus2/-/compare/6242e79a8bd5a21eb5496476d54ea7a13934d1d9...1910321f0dc9cca42a4e23d8377c4274f9ece97a
--
View it on GitLab: https://salsa.debian.org/med-team/libmaus2/-/compare/6242e79a8bd5a21eb5496476d54ea7a13934d1d9...1910321f0dc9cca42a4e23d8377c4274f9ece97a
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261101/71bf1754/attachment-0001.htm>
More information about the debian-med-commit
mailing list