8000 On ppc64, malloc gives misaligned buffers for glibc <= 2.23. · Issue #10491 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

On ppc64, malloc gives misaligned buffers for glibc <= 2.23. #10491

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

Open
ahaldane opened this issue Jan 29, 2018 · 2 comments
Open

On ppc64, malloc gives misaligned buffers for glibc <= 2.23. #10491

ahaldane opened this issue Jan 29, 2018 · 2 comments

Comments

@ahaldane
Copy link
Member
ahaldane commented Jan 29, 2018

On ppc64 and ppc64le systems, glibc 2.23-or-less has a bug in malloc, that it only guarantees alignment to 8 bytes, even though it should be 16 bytes.

https://sourceware.org/bugzilla/show_bug.cgi?id=6527

This is a problem for the long-double (float128) and sometimes complex128 type which should be aligned to 16 bytes. This means that when using long-double arrays, many internal numpy computations will randomly fail on ppc64, depending on what alignment malloc returned. This causes sporadic numpy unit test failures and sometimes outright crashes. The test numpy.core.tests.test_numeric TestRequire.test_require_each commonly fails, though not consistently.

Users on ppc64 should upgrade to glibc 2.24 or later.

(Discovered in #10443)

@jjhelmus
Copy link
Contributor

Does adding -malign-natural to the compiler flags have any effect on the alignment?

@ahaldane
Copy link
Member Author

Nope, I still get the error on glibc 2.23, C compiler: powerpc-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -malign-natural -fPIC (gcc 5.4.0).

Here is a test script I am running:

import sys
c = []
for i in range(1000):
    c.append(np.zeros(np.random.randint(10), dtype='f16'))
    if (c[-1].ctypes.data % 16) != 0:
    
84A8
    print("error:", c[-1].flags['A'], c[-1].ctypes.data)
        break

which shows I get 8-byte-only alignment sometimes. I also confirm test_require_each in the test suite still fails sometimes.

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

No branches or pull requests

2 participants
0