Karim BELABAS on Tue, 20 May 2003 18:47:18 +0200 (MEST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [Cygwin] MPQS broken


On Thu, 15 May 2003, Ilya Zakharevich wrote:
>>   I have just received a bug report that MPQS is completely broken under
>> Cygwin, at least compiled with gcc-3.2 (that's my XP binary, as available
>> in parigp-home.de's download area :-(). I can reproduce it on our Windows
>> box (XP), and of course nowhere else.
>>
>> Any invocation of mpqs(), e.g as in
>>
>>   factor(2^(2^7) + 1)
>>
>> causes a SEGV in mpqs.c:mpqs_mergesort_lp_file0(), more precisely in the first
>> fgets() [ line 400 ], within memcpy() in cygwin1.dll.
>>
>> This only occurs with -fomit-frame-pointer, at -O2 or higher so it doesn't
>> look like cygwin1.dll is to blame. It's independant of GCC_INLINE and works
>> flawlessly at -O1, or without -fomit-frame-pointer.
>>
>> I have absolutely no clue as to what could cause the bug. Just in case,
>> I have extended the size of some static arrays, e.g
>>
>>   line[MPQS_STRING_LENGTH] --> line[MPQS_STRING_LENGTH + 1024]
>
> This reading 4K chars to a stack.  What is the size of the stack?

Interesting trail, but red herring in the end: I played a little with
--stack, then replaced the static arrays by malloced data. And I still get
the SEGV [ assuming -O2 and -fomit-frame-pointer ].

Further info:

* I'm using gcc-3.2.3 [ latest available as Cygwin package, labelled
20020927 (prerelease) ].

* gp [-sta or -dyn doesn't matter] compiled with gcc-2.95.3-10 doesn't have
the bug.

It very much looks like an optimizer bug...

    Karim.
-- 
Karim Belabas                     Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425   Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud              http://www.math.u-psud.fr/~belabas/
F-91405 Orsay (France)            http://www.parigp-home.de/  [PARI/GP]