-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIN32] 64-bit long double build crashes in op/pack.t (was #125863) #14876
Comments
From @sisyphusHi, Tony Cook noted in #125863 that op/pack.t crashes because of a problem with
However, this issue is not related to the original subject of #125863, so It's a problem that affects 64-bit gcc-4.9.2 -Duselongdouble builds of As a workaround, I've successfully used the attached patch to pp_pack.c With this patch in place, there are no crashes in op/pack.t. The patch applies only when nvtype is 'long double' && the mingw compiler is I'm not sure whether we should be specifying "mingw runtime version is 4.x" Any thoughts/concerns re the patch ? Cheers, |
From @sisyphuspp_pack.c.patch--- pp_pack.c_orig 2015-08-27 21:36:40 +1000
+++ pp_pack.c 2015-08-27 22:10:52 +1000
@@ -1767,7 +1767,15 @@
}
while (cdouble < 0.0)
cdouble += anv;
+#if defined(USE_LONG_DOUBLE) && defined(__MINGW64__) && __MINGW64_VERSION_MAJOR == 4
+ /* modfl() segfaults for -Duselongdouble && 64-bit mingw && mingw runtime version 4 */
+ cdouble /= anv;
+ if(cdouble >= 0) trouble = floorl(cdouble);
+ else trouble = ceill(cdouble);
+ cdouble -= trouble;
+#else
cdouble = Perl_modf(cdouble / anv, &trouble);
+#endif
#ifdef LONGDOUBLE_DOUBLEDOUBLE
/* Workaround for powerpc doubledouble modfl bug:
* close to 1.0L and -1.0L cdouble is 0, and trouble
|
From @bulk88On Thu Aug 27 06:27:16 2015, sisyphus wrote:
What about mingw.org CCs? is there a bug ticket filed with mingw64 about this? The important thing about a version check is, when will W64 fix this and will they ever bump __MINGW64_VERSION_MAJOR? You don't want a deoptimized version in perl core, to stay forever in the code since it was forgotten about, even though mingw64 fixed the bug years ago. I will mention mingw64 changed the calling convention of libstdc++-6.dll between 4.6 and 4.8 from cdecl to thiscall, but never renamed the DLL, making it impossible to have 4.6 and 4.8 GCC DLLs in the same process, so I presume they are very conservative about version bumps. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @sisyphus-----Original Message-----
If there are mingw.org compilers that have this bug, then the patch will not The compiler/runtime combo's I have checked are: The only one of those that needs the patch is d). I probably ought to at least verify that the patch is *not* needed for
I don't know. I did mention in the #125863 discussion that I would
Exactly. This bothers me a bit. But that's certainly better than having de-optimised code being run when Cheers, |
From @sisyphus-----Original Message-----
Well, I don't think there's much doubt that the problem arises only with
There's a bug report for this (created 2015-05-07) at A patch to the mingw runtime is also available: Cheers, |
From @sisyphus-----Original Message-----
Ok ... so I've rewritten that patch to include the condition "&& But *then* I found that the crash in ext/POSIX/t/math.t occurs for the very But *now* I'm wondering whether I should instead be attacking this issue in Thoughts ?? I now get no crashes during the test suite, and I think the 2 attached Cheers, |
From @sisyphusPOSIX.xs.patch--- POSIX.xs_orig 2015-09-01 20:41:42 +1000
+++ POSIX.xs 2015-09-01 21:21:53 +1000
@@ -2864,8 +2864,17 @@
NV x
PPCODE:
NV intvar;
+#if defined(USE_LONG_DOUBLE) && defined(__MINGW64__) \
+ && __MINGW64_VERSION_MAJOR == 4 && __MINGW64_VERSION_MINOR == 0
+ /* modfl() segfaults for -Duselongdouble && 64-bit mingw64 && mingw runtime version 4.0 */
+ if(x >= 0) intvar = floorl(x);
+ else intvar = ceill(x);
+ x -= intvar;
/* (We already know stack is long enough.) */
+ PUSHs(sv_2mortal(newSVnv(x)));
+#else
PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar)))); /* C89 math */
+#endif
PUSHs(sv_2mortal(newSVnv(intvar)));
void
|
From @tonycozOn Tue Sep 01 05:12:53 2015, sisyphus wrote: + if(cdouble >= 0) trouble = floorl(cdouble); could be: trouble = truncl(cdouble); As to providing our own modfl() implementation, the main issue is we'd need to make sure it's exported so POSIX (or other XS modules) could see it. Though we could add it to inline.h Tony |
From @sisyphus-----Original Message-----
Yes, that is better.
I later tried altering perl.h so that, for the particular conditions, Here's the "proof-of-concept" patch to perl.h that I was using: Inline Patch--- perl.h_orig 2015-09-01 21:16:45 +1000
+++ perl.h 2015-09-02 00:54:07 +1000
@@ -1915,6 +1915,23 @@
I might have another go at it tonight.
I'm thinking that Perl_my_modfl() is already the "our own modfl() Cheers, |
From @tonycozOn Wed, Sep 02, 2015 at 12:11:40PM +1000, sisyphus1@optusnet.com.au wrote:
Mostly so we don't need to add Perl_my_modfl to the Win32 exports on a Or just wait for mingw-64 4.1 with a fixed modfl() -- though the fix Tony |
From @sisyphus-----Original Message-----
Aaah - so that's the reason I was getting the undefined reference to
That option is fine by me - this modfl bug isn't creating any problems for Let me know if there's anything else needs testing. Otherwise, I'm quite Cheers, |
From @sisyphusThe mingw64-w64 bug in modfl() that caused this issue has finally been fixed in runtime version 5.0.3, and there's now no need for 64-bit long double builds of perl to patch pp_pack.c and POSIX.c so long as the runtime version used does not fall in the range 4.0 to 5.0.2 (inclusive). Cheers, |
From @xsawyerxAre you suggesting to close the ticket? On 11/23/2017 10:57 AM, Sisyphus via RT wrote:
|
From @sisyphus-----Original Message-----
No - I just wanted to update the thread to reflect the current state of With the compilers used by all recent builds of 64-bit Strawberry Perl (and The correct thing to do would be to fix the perl source, then close the The condition I use to determine whether modfl needs to be worked around (in #if defined(USE_LONG_DOUBLE) && defined(__MINGW64__) && And, of course, that will still perform the workaround when runtime version Having said all that, if you think the ticket should be closed, I've no Cheers, |
This was fixed upstream in https://sourceforge.net/p/mingw-w64/mingw-w64/ci/9a2479858b3bb7df36a09c4472fa1adca7e84f19/ I don't think we need to do anything further. Closing. |
Migrated from rt.perl.org#125924 (status was 'open')
Searchable as RT125924$
The text was updated successfully, but these errors were encountered: