From: Paul Floyd Date: Wed, 5 Jun 2024 19:01:22 +0000 (+0200) Subject: Bug 487993 - Alignment error when using Eigen with Valgrind and -m32 X-Git-Tag: VALGRIND_3_24_0~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d66d3ab3017582ee41c459b812f695af405da44c;p=thirdparty%2Fvalgrind.git Bug 487993 - Alignment error when using Eigen with Valgrind and -m32 Not tested on Solaris, but I think that x86 is more or less unused on that platform these days. --- diff --git a/.gitignore b/.gitignore index 2736719ba..3bdbe1042 100644 --- a/.gitignore +++ b/.gitignore @@ -1330,6 +1330,7 @@ /memcheck/tests/x86/Makefile.in /memcheck/tests/x86/bug133694 /memcheck/tests/x86/bug152022 +/memcheck/tests/x86/bug487993 /memcheck/tests/x86/espindola2 /memcheck/tests/x86/fpeflags /memcheck/tests/x86/fprem diff --git a/NEWS b/NEWS index 92e669e31..4d7a97c9d 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 'guest_IP_AT_SYSCALL' 486293 memccpy false positives 486569 linux inotify_init syscall wrapper missing POST entry in syscall_table +487993 Alignment error when using Eigen with Valgrind and -m32 488026 Use of `sizeof` instead of `strlen To see details of a given bug, visit diff --git a/coregrind/pub_core_mallocfree.h b/coregrind/pub_core_mallocfree.h index bbde837e2..6f0cd293b 100644 --- a/coregrind/pub_core_mallocfree.h +++ b/coregrind/pub_core_mallocfree.h @@ -61,8 +61,7 @@ typedef Int ArenaId; // This is both the minimum payload size of a malloc'd block, and its // minimum alignment. Must be a power of 2 greater than 4, and should be // greater than 8. -#if defined(VGP_x86_linux) || \ - defined(VGP_arm_linux) || \ +#if defined(VGP_arm_linux) || \ defined(VGP_mips32_linux) || \ (defined(VGP_mips64_linux) && defined(VGABI_N32)) || \ defined(VGP_nanomips_linux) || \ @@ -72,7 +71,8 @@ typedef Int ArenaId; // for any AltiVec- or SSE-related type. This matches the Darwin libc. // Also, use 16 bytes for any PPC variant, since 16 is required to make // Altiveccery work right. -#elif defined(VGP_amd64_linux) || \ +#elif defined(VGP_x86_linux) || \ + defined(VGP_amd64_linux) || \ defined(VGP_ppc32_linux) || \ defined(VGP_ppc64be_linux) || \ defined(VGP_ppc64le_linux) || \ diff --git a/memcheck/tests/x86/Makefile.am b/memcheck/tests/x86/Makefile.am index dc93c85b9..6d0d6a198 100644 --- a/memcheck/tests/x86/Makefile.am +++ b/memcheck/tests/x86/Makefile.am @@ -9,6 +9,7 @@ INSN_TESTS = insn_basic insn_fpu insn_cmov insn_mmx insn_mmxext insn_sse insn_ss EXTRA_DIST = \ bug152022.vgtest bug152022.stderr.exp bug152022.stdout.exp \ + bug487993.vgtest bug487993.stderr.exp \ espindola2.vgtest espindola2.stderr.exp \ fpeflags.stderr.exp fpeflags.vgtest \ fxsave.vgtest fxsave.stdout.exp fxsave.stderr.exp \ @@ -53,6 +54,11 @@ AM_CFLAGS += @FLAG_M32@ $(FLAG_MMMX) $(FLAG_MSSE) AM_CXXFLAGS += @FLAG_M32@ $(FLAG_MMMX) $(FLAG_MSSE) AM_CCASFLAGS += @FLAG_M32@ +if HAVE_CXX17 +check_PROGRAMS += bug487993 +bug487993_SOURCES = bug487993.cpp +bug487993_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 +endif # fpeflags must use these flags -- bug only occurred with them. fpeflags_CFLAGS = $(AM_CFLAGS) -march=i686 diff --git a/memcheck/tests/x86/bug487993.cpp b/memcheck/tests/x86/bug487993.cpp new file mode 100644 index 000000000..27f43d306 --- /dev/null +++ b/memcheck/tests/x86/bug487993.cpp @@ -0,0 +1,20 @@ +// the original issue ocurred with Eigen3 +// this is roughly the same using a simple struct +// +#include +#include +//#include + +struct Test +{ + alignas(16) double array[16]; +}; + +int main() +{ + std::unique_ptr test = std::make_unique(); + //std::cerr << "test " << test.get() << ' ' << (reinterpret_cast(test.get()) & 0xfUL) << '\n'; + assert((reinterpret_cast(test.get()) & 0xfUL) == 0); +} + + diff --git a/memcheck/tests/x86/bug487993.stderr.exp b/memcheck/tests/x86/bug487993.stderr.exp new file mode 100644 index 000000000..e69de29bb diff --git a/memcheck/tests/x86/bug487993.vgtest b/memcheck/tests/x86/bug487993.vgtest new file mode 100644 index 000000000..ca5db1515 --- /dev/null +++ b/memcheck/tests/x86/bug487993.vgtest @@ -0,0 +1,3 @@ +prereq: test -e bug487993 +prog: bug487993 +vgopts: -q