This forum has been archived. All content is frozen. Please use KDE Discuss instead.

VS2013 Aligned Memory Errors with dynamically-linked library

Tags: None
(comma "," separated)
Shmuel.Levine
Registered Member
Posts
1
Karma
0
Hi,
I've been using Eigen in my software, and I've run into an issue today, caused by changing my code from building a static library to dynamic library in Windows, using Visual Studio 2013. The reason for this switch was not related to Eigen.

I am embedding Eigen in my own library file, which itself is then linked into my application(s). As mentioned before, this library had been a static library until today; I have just updated my codebase to generate a DLL file instead.

Since making this change, I am now getting the following error message from Visual Studio:

The Block at -------------------- was allocated by aligned routines, use _aligned_free()

(that this message pops up numerous times with different addresses each time; I've used dashes above, as I don't believe that the specific addresses are relevant to this issue).

choosing "retry" opens the debugger to line 255 on Memory.h

Visual studio IntelliSense (when not debugging) suggests that EIGEN_ALIGN and EIGEN_HAS_MM_MALLOC are both defined as 1, EIGEN_MALLOC_ALREADY_ALIGNED and EIGEN_HAS_POSIX_MEMALIGN are both undefined. Accordingly, it should be running _mm_free(ptr), which (again-based from IntelliSense) is an alias for _aligned_free(a). As such, it appears that this code should be running the correct function, but it isn't.

When I change the code back to a static library, this issue goes away.

The only thing remotely relevant that I found from numerous Google searches was an article from Intel Fortran Compiler saying that this error message might come from a library which was compiled in an earlier version that is called by code compiled with the latest version. Aside from the fact that I am using Visual Studio C++ 2013, I have rebuilt the code numerous times to be sure that it is all fully recompiled from a clean state and this error message persists.

I have downloaded the latest code from the mercurial repo (default branch), but this did not solve the problem.

Edit:
A short additional bit of context and clarification:
I am not trying to allocate the memory in the DLL file and de-allocate it from the client application, or something else similarly evil. The client app is my unit test framework (I'm using Google Test, although I don't think that matters in this context). The code crashes after running a specific test -- i.e. running a destructor for a temporary object.

I've tried to be as thorough as I could be. If you need any more information, please let me know.

Thanks-
Shmuel
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Can you tell us the precise version of Eigen so that we can known which line corresponds line 255. Also make sure you tried with latest Eigen version.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]