[eigen] SEGFAULTs after changeset 537b5d33b440 (+patch) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] SEGFAULTs after changeset 537b5d33b440 (+patch)
- From: Jose Luis Blanco <joseluisblancoc@xxxxxxxxx>
- Date: Wed, 5 Jan 2011 03:16:34 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=xcgHticmh4a7MJyQT1jyTin9R5sWxXFn/IDSR17dIsE=; b=fDa0yMMNCkRriLrFJGkh/9zLgIJCPgf/PIZuWSJlpa3AKKBzb9vtsrrXYtgXFk9MKd 5hLh6FvF3aKLCRs30YbZZIjjab8dSj8HItBA03CtqmWGYHgjZlLm8Jjtrz2f03WXsvXL Pewg/6uNHoWeTDnj2+fJtt5tgU2CVynlW/XoQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=il9cnKp7u7yz9eK13kSEjesFtly6xSknjxL7AjLnJQWtnIDeZLfQwsIoWujdIQBpU9 x9FWjf6sTuPd9ndsBIUWqU0Hf5uGaDxDsukhRRFBCD0jfcHZ1iCetEMSmCpZ0+UcVaax dHQgR+fQT0m87F5mg7b9vQTSCiYbGpyvGYw4s=
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
# HG changeset patch
# User Jose Luis Blanco <joseluisblancoc@xxxxxxxxx>
# Date 1294191823 -3600
# Node ID b010ba908e571b090315631881d76b43d218049b
# Parent de9d6db42d0600f7300f57fee3627a2493632171
Update of CPUID macros to fix segfaults in amd64 code.
diff -r de9d6db42d06 -r b010ba908e57 Eigen/src/Core/util/Memory.h
--- a/Eigen/src/Core/util/Memory.h Tue Jan 04 15:35:50 2011 +0100
+++ b/Eigen/src/Core/util/Memory.h Wed Jan 05 02:43:43 2011 +0100
@@ -598,10 +598,12 @@
//---------- Cache sizes ----------
#if defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
-# if defined(__PIC__)
+# 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