Skip to content
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

using long double c++ math functions result in a segfault with mingwpy's gcc 4.9.2 #22

Open
EdwinBennink opened this issue Apr 21, 2016 · 2 comments
Labels

Comments

@EdwinBennink
Copy link

I noticed that using c++ math functions (like std::fmod) with long doubles result in a segfault using the current mingwpy version. This is gcc version 4.9.2 (x86_64-win32-seh-rev201506, mingwpy build).

Nathanial smith suggested:

Maybe the problem is that libstdc++ is getting compiled with -mlong-double-80, and that has ABI effects that make it incompatible with code compiled with -mlong-double-64? Is mingwpy's tweak of the spec file defaults happening before or after libstdc++ gets built?

To reproduce the segfault, compile foo.cxx below without any compiler flags:

#include <cstdio>
#include <cmath>

int main()
{       
    printf("fmod -> %f\n", fmod((long double)1, 16));
    printf("std::fmod -> %f\n", std::fmod((long double)1, 16));

    return 0;
}

Forcing 80 bit long doubles by adding the -mlong-double-80 compiler flag and including CRT_fp10.o does not fix the issue, probably since the mlong-double-64 flag is hardcoded in the 4.9.2 compiler specs.

@carlkl carlkl added the bug label Apr 21, 2016
@EdwinBennink
Copy link
Author

EdwinBennink commented Apr 28, 2016

The following issue with numpy is probably connected. I built numpy 1.11.0 for Python 3.4.4 (Win64) with mingwpy's gcc 4.9.2 (x86_64-win32-seh-rev201506). The following python code resulted in a segfault when calling fmodl:

import numpy
import operator
a = numpy.array([1, 2, 3], dtype='g')
[operator.floordiv(a_, b_) for a_, b_ in zip(a,a)]

Backtrace:

#0  0x000000006c08cad0 in fmodl () from /d/develop/release/lib/site-packages/numpy-1.11.0-py3.4-win-amd64.egg/numpy/core/umath.pyd
#1  0x000000006c07fccc in npy_fmodl (y=1, x=1) at numpy/core/src/npymath/npy_math.c.src:482
#2  npy_divmodl (a=1, b=1, modulus=0x2ef218) at numpy/core/src/npymath/npy_math.c.src:621
#3  0x000000006c067cf7 in longdouble_ctype_floor_divide (out=0x2ef210, b=<optimized out>, a=<optimized out>) at numpy/core/src/umath/scalarmath.c.src:288
#4  longdouble_floor_divide (a=<optimized out>, b=0x38013a8) at numpy/core/src/umath/scalarmath.c.src:862
#5  0x0000000062d1732f in python34!_PyFloat_Unpack8 () from /d/develop/release/python34.dll

@carlkl
Copy link
Contributor

carlkl commented Apr 29, 2016

as mingwpy handles long doubles identical to doubles numpy (hint: MSVC compatibility) has to take care of it during build.

That was the case with a recently refused numpy PR. This PR has to be rebuild (be my) and published again. When this is done, is should be possible to build numpy with mingwpy again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants