Hello everyone,
I have run into a very strange problem and I am not sure what might be causing
it. I am compiling the latest svn of gmp-ecm (right now it is 1746) and
depending on whether I insert a few extra print statements or not, one certain
test in gmp-ecm will either run to completion or will seg_fault. Can someone
here help me test whether this might be a problem with MingW64, Win XP x64,
MPIR
2.5.0, or maybe something else? I have run into the problem with two different
sezero builds (20101003 and 20111101) as my MingW64 compiler. I am compiling
inside an MSYS shell (1.0.16). I am on a Windows XP x64 computer.
Steps to reproduce the problem I am seeing:
0) Use MPIR as your GMP library and MingW64 as your compiler
1) Download latest gmp-ecm svn (currently 1746)
2) run 'autoreconf -i'
3) I configure with the following options:
./configure CC=gcc CFLAGS="-O2 -pedantic -m64 -std=gnu99 -mtune=core2
-march=core2" --enable-asm-redc --build=x86_64-w64-mingw32 --disable-assert
4) run 'make'
At this point we can just run the test that fails for me, it is (sorry for any
wrap around):
echo
449590253344339769860648131841615148645295989319968106906219761704350259884936939123964073775456979170209297434164627098624602597663490109944575251386017
| ecm -sigma 63844855 -go 172969 61843 20658299
The test should produce a 27 digit factor of the 153 digit input. However, in
my setup it seg_faults, actually just a silent crash with no screen output.
Now, I have been using some printf's (actually outputf in gmp-ecm code) to try
to track down where the crash was happening. I have found that if I put three
outputf statements in one part of the code, the program runs successfully and
produces the factorization. Can anyone else here reproduce this problem? I'm
curious to see if this problem happens for anyone else on WinXP x64, or maybe
on
Win7 x64.
If anyone can reproduce the crash, can you see if the following change fixes
the
problem in your environment? The diff just applies to one file, mpmod.c.
$ diff -u ../svn/mpmod.c mpmod.c
--- ../svn/mpmod.c 2012-02-12 19:59:32 -0600
+++ mpmod.c 2012-02-19 14:48:36 -0600
@@ -719,8 +719,11 @@
#endif /* otherwise go through to the next available mode */
case MPMOD_MUL_REDC3: /* mpn_mul_n + ecm_redc3 */
#if defined(HAVE_ASM_REDC3)
+outputf(OUTPUT_VERBOSE, "tmp0=0x%I64x tmp1=0x%I64x tmp2=0x%I64x\n", tmp[0],
tmp[1], tmp[2]);
mpn_sqr (tmp, s1p, nn);
+outputf(OUTPUT_VERBOSE, "tmp0=0x%I64x tmp1=0x%I64x tmp2=0x%I64x\n", tmp[0],
tmp[1], tmp[2]);
ecm_redc3 (tmp, np, nn, invm[0]);
+outputf(OUTPUT_VERBOSE, "tmp0=0x%I64x tmp1=0x%I64x tmp2=0x%I64x\n", tmp[0],
tmp[1], tmp[2]);
cy = mpn_add_n (rp, tmp + nn, tmp, nn);
if (cy != 0)
mpn_sub_n (rp, rp, np, nn); /* a borrow should always occur here
*/
At this point, if you run 'make clean' and 'make' again, then run the test case
from up above, it should produce a factor very quickly.
For some strange reason, all three of the 'outputf' statements above are
necessary to make gmp-ecm run to completion. If any of those 'outputf'
statements are left out, then the program will silently crash.
My guess is that there is some assembly code in gmp-ecm (the ecm_redc3
function,
found in ecm_svn_1746/x86_64/redc.asm) that MingW64 might not be processing
correctly. This is just a guess based on the fact that the crash happens with
both MPIR and GMP (it only happens to GMP if it goes through the same code path
as MPIR, ask me for the change if you would like to see it with GMP).
Is anyone willing to help me track this problem down? Is there any more
information that anyone needs to look into this problem? Thanks for your time
and I'll talk with you later.
-David C.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public