Currently Eigen assumes glibc malloc() returns 16-byte aligned address for all LP64 systems. Now gcc 4.8 introduces address sanitizer (-fsanitize=address), which is a very powerful tool that effectively detect memory-related bugs. Unfortunately, when this switch is turned on, the pointer returned by malloc() no longer aligned at 16-byte alignment, and breaks Eigen assumption. For a quick fix, I propose the following patch: --- Eigen/src/Core/util/Memory.h 2013-02-09 00:20:40.000000000 +0900 +++ Eigen/src/Core/util/Memory.h.new 2013-02-09 00:20:51.000000000 +0900 @@ -27,7 +27,7 @@ // page 114, "[The] LP64 model [...] is used by all 64-bit UNIX ports" so it's indeed // quite safe, at least within the context of glibc, to equate 64-bit with LP64. #if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 8) || __GLIBC__>2) \ - && defined(__LP64__) + && defined(__LP64__) && ! defined( __SANITIZE_ADDRESS__ ) #define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 1 #else #define EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED 0
Good catch! In fact, I think that we should just remove EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED altogether: it doesn't buy us much as we're able to use aligned malloc functions just as well, and it's likely to cause other problems with other kinds of malloc instrumentation.
It still looks better to simply rely on malloc when possible, so: https://bitbucket.org/eigen/eigen/commits/fade198d789b/ changeset: fade198d789b user: ggael date: 2013-02-25 19:17:13 summary: Fix bug 552: disable EIGEN_GLIBC_MALLOC_ALREADY_ALIGNED when compiling with -fsanitize=address, and allow users to manually tell whether EIGEN_MALLOC_ALREADY_ALIGNED.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/552.