numenta / nupic.core-legacy

Implementation of core NuPIC algorithms in C++ (under construction)
http://numenta.org
GNU Affero General Public License v3.0
272 stars 276 forks source link

Connections.mapSegmentsToCells() segfaults in debug builds #1331

Closed mrcslws closed 7 years ago

mrcslws commented 7 years ago

In debug builds, when this code runs inside the algorithms.so module, it segfaults: https://github.com/numenta/nupic.core/blob/d33caa0bde7d643a41436558ca2531c99546b783/src/nupic/py_support/NumpyVector.hpp#L425

The assertion isn't actually failing. The call to PyArray_EquivTypenums causes a bad memory access. This is a macro for

#define PyArray_EquivTypenums \
        (*(unsigned char (*)(int, int)) \
         PyArray_API[191])

There's a PyArray_API array that contains a bunch of function pointers, and it's not getting properly populated.

The solution is: we need to include this line in algorithms.i: https://github.com/numenta/nupic.core/blob/d33caa0bde7d643a41436558ca2531c99546b783/src/nupic/bindings/math.i#L90

In htmresearch-core we also need this line in experimental.i.