Changeset: b586d75b6a1d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b586d75b6a1d Modified Files: monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh monetdb5/extras/pyapi/pyapi.c Branch: pyapi Log Message:
Fixed segfault when testing with NPY_STRING option. diffs (66 lines): diff --git a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh --- a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh +++ b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh @@ -122,7 +122,7 @@ function pyapi_build { fi fi echo "Finished testing for libraries. Downloading and installing MonetDB." - wget $PYAPI_TAR_URL && tar xvzf pyapi.tar.gz && cd $PYAPI_MONETDB_DIR && ./bootstrap && ./configure prefix=$PYAPI_BUILD_DIR && make -j install + wget $PYAPI_TAR_URL && tar xvzf pyapi.tar.gz && cd $PYAPI_MONETDB_DIR && ./bootstrap && ./configure prefix=$PYAPI_BUILD_DIR --enable-debug=no --enable-assert=no --enable-optimize=yes && make -j install if [ $? -ne 0 ]; then echo "Failed to download and install MonetDB. Exiting..." return 1 diff --git a/monetdb5/extras/pyapi/pyapi.c b/monetdb5/extras/pyapi/pyapi.c --- a/monetdb5/extras/pyapi/pyapi.c +++ b/monetdb5/extras/pyapi/pyapi.c @@ -754,13 +754,12 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st if (pyinput_values[i - (pci->retc + 2)].scalar) { result_array = PyArrayObject_FromScalar(&pyinput_values[i - (pci->retc + 2)], &msg); } else { -#ifdef PYAPI_TESTING +#ifdef _PYAPI_TESTING_ if (option_lazyarray) { result_array = PyLazyArray_FromBAT(pyinput_values[i - (pci->retc + 2)].bat); } else #endif { - //result_array = PyLazyArray_FromBAT(pyinput_values[i - (pci->retc + 2)].bat); result_array = PyMaskedArray_FromBAT(&pyinput_values[i - (pci->retc + 2)], t_start, t_end, &msg); } } @@ -814,7 +813,6 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st // The function has been successfully created/compiled, all that remains is to actually call the function pResult = PyObject_CallObject(pFunc, pArgs); - //Py_DECREF(pArgs); Py_DECREF(pFunc); if (PyErr_Occurred()) { @@ -1810,6 +1808,7 @@ PyObject *PyArrayObject_FromBAT(PyInput BAT_TO_NP(b, dbl, NPY_FLOAT64); break; case TYPE_str: + option_numpy_string_array = true; #ifdef _PYAPI_TESTING_ if (option_numpy_string_array) { bool unicode = false; @@ -1871,7 +1870,8 @@ PyObject *PyArrayObject_FromBAT(PyInput msg = createException(MAL, "pyapi.eval", "Failed to decode string as UTF-8."); goto wrapup; } - ((PyObject**)PyArray_DATA((PyArrayObject*)vararray))[j - t_start] = obj; + PyArray_SETITEM((PyArrayObject*)vararray, PyArray_GETPTR1((PyArrayObject*)vararray, j - t_start), obj); + Py_DECREF(obj); } if (j == t_end) break; j++; @@ -1902,7 +1902,8 @@ PyObject *PyArrayObject_FromBAT(PyInput msg = createException(MAL, "pyapi.eval", "Failed to create string."); goto wrapup; } - ((PyObject**)PyArray_DATA((PyArrayObject*)vararray))[j - t_start] = obj; + PyArray_SETITEM((PyArrayObject*)vararray, PyArray_GETPTR1((PyArrayObject*)vararray, j - t_start), obj); + Py_DECREF(obj); } if (j == t_end) break; j++; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list