[go: up one dir, main page]

GCC address sanitizer breaks 16-byte alignment of glibc malloc

Submitted by Takaki Makino

Assigned to Nobody

Link to original bugzilla bug (#552)
Version: 3.2
Operating system: Linux

Description

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

Blocking

#387 (closed)

Edited by Eigen Bugzilla