Re: [eigen] SEGFAULTs after changeset 537b5d33b440 (+patch)

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

Jose Luis, thanks for figuring this out! Is this fixed already in the
repository? (Sorry, I am still learning hg...)

Cheers,
Hauke

On Wed, Jan 5, 2011 at 2:16 AM, Jose Luis Blanco
<joseluisblancoc@xxxxxxxxx> wrote:
> Hi all,
>
> I've been struggling this last week to find out why *several* parts of
> my code suddenly stopped working with Eigen3, and I finally nailed
> down the specific change that makes the code crashes, and it's about
> the CPUID macros changed in 537b5d33b440.
> It turned out that the logic of the #if's wasn't maintained in the
> change, and it seems to me that the "xchgl ..." instruction was
> invoked instead of the "cpuid...".
>
> I attach a patch that fixes it (tested in gcc + amd64), but please,
> someone with a good understanding of what is the __PIC__ supposed to
> do here, take a careful look at the resulting code:
>
> ===============================
> //---------- Cache sizes ----------
>
> #if defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
> #  if defined(__PIC__) && defined(__i386__)
>     // Case for x86 with PIC
> #    define EIGEN_CPUID(abcd,func,id) \
>       __asm__ __volatile__ ("xchgl %%ebx, %%esi;cpuid; xchgl
> %%ebx,%%esi": "=a" (abcd[0]), "=S" (abcd[1]), "=c" (abcd[2]), "=d"
> (abcd[3]) : "a" (func), "c" (id));
> #  else
>     // Case for x86_64 or x86 w/o PIC
> #    define EIGEN_CPUID(abcd,func,id) \
>       __asm__ __volatile__ ("cpuid": "=a" (abcd[0]), "=b" (abcd[1]),
> "=c" (abcd[2]), "=d" (abcd[3]) : "a" (func), "c" (id) );
> #  endif
> #elif defined(_MSC_VER)
> #  if (_MSC_VER > 1500) /* newer than MSVC++ 9.0 */ || (_MSC_VER ==
> 1500 && _MSC_FULL_VER >= 150030729) /* MSVC++ 9.0 with SP1*/
> #    define EIGEN_CPUID(abcd,func,id) __cpuidex((int*)abcd,func,id)
> #  endif
> #endif
>
> ===============================
>
> btw, if it helps, in all my builds __PIC__ seems to be predefined by GCC.
>
> Thanks in advance!
>
> JL
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/