]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 487993 - Alignment error when using Eigen with Valgrind and -m32
authorPaul Floyd <pjfloyd@wanadoo.fr>
Wed, 5 Jun 2024 19:01:22 +0000 (21:01 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Wed, 5 Jun 2024 19:01:22 +0000 (21:01 +0200)
Not tested on Solaris, but I think that x86 is more or less unused
on that platform these days.

.gitignore
NEWS
coregrind/pub_core_mallocfree.h
memcheck/tests/x86/Makefile.am
memcheck/tests/x86/bug487993.cpp [new file with mode: 0644]
memcheck/tests/x86/bug487993.stderr.exp [new file with mode: 0644]
memcheck/tests/x86/bug487993.vgtest [new file with mode: 0644]

index 2736719bad0864769535c6cba033f9d671b01555..3bdbe1042d9b17d00dc940a765ddeb78440c13c5 100644 (file)
 /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 92e669e311317aa6560bf05030a2b23b7715e6d3..4d7a97c9d7e51aff0015fc09f1b143836cae74ea 100644 (file)
--- 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
index bbde837e2c428a226f309dc1b6eb7f47961c9818..6f0cd293bf0a881672f08cbc120e9460465d3435 100644 (file)
@@ -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)  || \
index dc93c85b962d9c47872f77e8e65906e80fb94cfd..6d0d6a1983fefe215b3ecf61ef761232be1fdc9a 100644 (file)
@@ -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 (file)
index 0000000..27f43d3
--- /dev/null
@@ -0,0 +1,20 @@
+// the original issue ocurred with Eigen3
+// this is roughly the same using a simple struct
+// 
+#include <cassert>
+#include <memory>
+//#include <iostream>
+
+struct Test
+{
+    alignas(16) double array[16];
+};
+
+int main()
+{
+    std::unique_ptr<Test> test = std::make_unique<Test>();
+    //std::cerr << "test " << test.get() << ' ' << (reinterpret_cast<size_t>(test.get()) & 0xfUL) << '\n';
+    assert((reinterpret_cast<size_t>(test.get()) & 0xfUL) == 0);
+}
+
+    
diff --git a/memcheck/tests/x86/bug487993.stderr.exp b/memcheck/tests/x86/bug487993.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/x86/bug487993.vgtest b/memcheck/tests/x86/bug487993.vgtest
new file mode 100644 (file)
index 0000000..ca5db15
--- /dev/null
@@ -0,0 +1,3 @@
+prereq: test -e bug487993
+prog: bug487993
+vgopts: -q