For information I can reproduce this issue and, effectively, the patch
fixes it on my Windows 11.

Le jeu. 17 oct. 2024 à 14:06, Qian Yun <[email protected]> a écrit :
>
> Solved.
>
> diff --git a/src/lib/gmp_wrap.c b/src/lib/gmp_wrap.c
> index a1065104..45e3fa7b 100644
> --- a/src/lib/gmp_wrap.c
> +++ b/src/lib/gmp_wrap.c
> @@ -165,7 +165,7 @@ gmp_wrap_gcd(mp_limb_t * rp, mp_limb_t *s1p,
>           rp[res] = rc;
>           res++;
>       }
> -    if (rp[res - 1] & (1ul << (BIT_CNT - 1))) {
> +    if (rp[res - 1] & (1ull << (BIT_CNT - 1))) {
>           rp[res] = 0;
>           res++;
>       }
>
> On Windows, 1ul (unsigned long) is 4 bytes instead of 8.
> So changing to 1ull fixes this.
>
> Actually there is compiler warning on this line on Windows:
>
> ../../../fricas/src/lib/gmp_wrap.c: In function 'gmp_wrap_gcd':
> ../../../fricas/src/lib/gmp_wrap.c:168:28: warning: left shift count >=
> width of type [-Wshift-count-overflow]
>    168 |     if (rp[res - 1] & (1ul << (BIT_CNT - 1))) {
>        |                            ^~
>
> - Qian
>
> On 10/16/24 12:48 PM, Qian Yun wrote:
> > The correct answer is 13936666434531148641,
> > and 13936666434531148641+4510077639178402975=2^64
> >
> > So looks like a sign error.
> >
> > - Qian
> >
> > On 10/16/24 12:30 PM, Qian Yun wrote:
> >> On Windows, build fricas with CCL (Clozure CL) and gmp support,
> >> the build is successfully, but when running tests, there are a
> >> few places (for example first test in bugs2018.input) where
> >> FRICASsys enters into infinite loop and I can observe memory
> >> is leaking. (to 10GB.)
> >>
> >> This does not happen if I disable GMP support.
> >>
> >> Luckily this problem is easy to reproduce, and backtrace
> >> easily points to this minimal reproducible example:
> >>
> >> (1) -> gcd(4068020004323239869867049777123762790865,
> >> 238106358327114453439438371357)
> >>
> >>
> >>     (1)  - 4510077639178402975
> >>
> >> - Qian
> >>
> >
>
> --
> You received this message because you are subscribed to the Google Groups 
> "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/fricas-devel/7018f201-d163-4fff-8dff-00f513672b2c%40gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAHnU2db3XWOztizCELJ9_UQ%2BG2PM8TprGjDjt1qBvVwqnY0kkA%40mail.gmail.com.

Reply via email to