robbmcleod / pyfastnoisesimd

Python module wrapping C++ FastNoiseSIMD
BSD 3-Clause "New" or "Revised" License
39 stars 6 forks source link

SIGABRT when trying to generate grid of odd sizes #21

Open tcdude opened 4 years ago

tcdude commented 4 years ago

I'm not sure whether this is expected behavior or not:

My setup:

The code:

import pyfastnoisesimd as fns

n = fns.Noise()
for _ in range(10):
    res = n.genAsGrid([1, 257, 257])

If this is expected behavior, than catching the wrong input would be great. Right now Python crashes with the following message:

malloc(): corrupted top size
Aborted (core dumped)

It does this with all odd numbers I tried (45, 513, 1025, ...)

robbmcleod commented 4 years ago

Well the array dimensions do have to be divisible by the SIMD vector length (so 2 for SSE2, 4 for AVX2, and 8 for AVX512).

However, there should be a check to raise a ValueError if the array sizes are appropriate rather than just core-dumping, so I'll look into that.

robbmcleod commented 4 years ago

Weird, array shapes like (127, 127, 1) do work as best I can tell. Let me think about it a bit, I'm not sure what the exact problem is. For example, the tests have been running successfully forever on array sizes like [98, 98] , which isn't a SIMD vector length. I made a potential fix is in be68e58fed9a9686ea481791524f6ddb97dafe17, but I'm not entirely sure the SIMD vector length is responsible. Unfortunately the underlying library doesn't provide a lot of error checks.