Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,44 @@ jobs:
- run: echo VALGRIND_ARGS="--tool=massif --massif-out-file=./${{ env.MASSIF_REPORT_FILE_NAME }}" >> $GITHUB_ENV
if: ${{ inputs.massif }}

- run: echo VALGRIND_ARGS="--leak-check=full" >> $GITHUB_ENV
#- run: echo VALGRIND_ARGS="--leak-check=full --gen-suppressions=all --suppressions=./valgrind-suppression/new_tests.supp --suppressions=./valgrind-suppression/file-suppressions/${{ github.event.inputs.test-file }}.supp --num-callers=350 --error-limit=no" >> $GITHUB_ENV
# if: ${{ !inputs.massif && github.event.inputs.test-file != '' }}

- run: echo VALGRIND_ARGS="--leak-check=full --gen-suppressions=all --suppressions=./valgrind-suppression/new_tests.supp --num-callers=350 --error-limit=no" >> $GITHUB_ENV
if: ${{ !inputs.massif && github.event.inputs.test-file != '' }}

- run: echo VALGRIND_ARGS="--leak-check=full --gen-suppressions=all --suppressions=./valgrind-suppression/new_tests.supp --suppressions=./valgrind-suppression/file-suppressions/${{ github.event.inputs.test-file }}.supp --num-callers=350 --error-limit=no " >> $GITHUB_ENV
if: ${{ !inputs.massif && github.event.inputs.test-file == '' }}

- run: PYTHONMALLOC=malloc valgrind --error-exitcode=1 ${{ env.VALGRIND_ARGS }} python3 -m pytest -v new_tests/${{ github.event.inputs.test-file }} 2>&1 | tee valgrind.log
working-directory: test

- run: |
python3 valgrind-suppression/extract_suppressions.py valgrind.log {{ github.event.inputs.test-file }}.supp
cat {{ github.event.inputs.test-file }}.supp
working-directory: test
if: ${{ !inputs.massif }}

- run: PYTHONMALLOC=malloc valgrind --error-exitcode=1 ${{ env.VALGRIND_ARGS }} python3 -m pytest -v new_tests/${{ github.event.inputs.test-file }}
- name: Upload suppression file
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.test-file }}.supp
path: test/{{ github.event.inputs.test-file }}.supp
if: ${{ !inputs.massif }}

- run: |
python3 valgrind-suppression/filter_suppressions.py new_suppressions.supp filtered_{{ github.event.inputs.test-file }}.supp
cat filtered_{{ github.event.inputs.test-file }}.supp
working-directory: test
if: ${{ !inputs.massif }}

- name: Upload filter suppressions file
uses: actions/upload-artifact@v4
with:
name: filtered_${{ github.event.inputs.test-file }}.supp
path: test/filtered_{{ github.event.inputs.test-file }}.supp
if: ${{ !inputs.massif }}

# TODO: upload report as artifact
- run: ms_print ./${{ env.MASSIF_REPORT_FILE_NAME }}
if: ${{ !cancelled() && inputs.massif }}
working-directory: test
Expand Down
17 changes: 15 additions & 2 deletions src/main/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ as_status as_partitions_status_to_pyobject(
Py_XDECREF(py_id);
goto END;
}
// Must be decref'd because PyDict_SetItem does not steal a reference
Py_DECREF(new_py_tuple);
Py_DECREF(py_id);
}

Expand Down Expand Up @@ -1308,10 +1310,15 @@ as_status as_val_new_from_pyobject(AerospikeClient *self, as_error *err,
Py_DECREF(py_parameter);

PyObject *geospatial_dump = AerospikeGeospatial_DoDumps(py_data, err);
Py_XDECREF(py_data);
if (!geospatial_dump) {
PyErr_Clear();
return as_error_update(err, AEROSPIKE_ERR_CLIENT,
"Unable to call dumps function");
}
const char *geo_value = PyUnicode_AsUTF8(geospatial_dump);
char *geo_value_cpy = strdup(geo_value);

Py_DECREF(py_data);
Py_DECREF(geospatial_dump);

*val = (as_val *)as_geojson_new(geo_value_cpy, true);
Expand Down Expand Up @@ -2231,6 +2238,13 @@ void initialize_bin_for_strictypes(AerospikeClient *self, as_error *err,
else if (!strcmp(py_value->ob_type->tp_name, "aerospike.Geospatial")) {
PyObject *geo_data = PyObject_GetAttrString(py_value, "geo_data");
PyObject *geo_data_py_str = AerospikeGeospatial_DoDumps(geo_data, err);
Py_XDECREF(geo_data);
if (!geo_data_py_str) {
PyErr_Clear();
as_error_update(err, AEROSPIKE_ERR_CLIENT,
"Unable to call dumps function");
return;
}
const char *geo_data_str = PyUnicode_AsUTF8(geo_data_py_str);

// Make a copy of the encoding since the utf8 encoding points to a buffer in the PyUnicode object
Expand All @@ -2243,7 +2257,6 @@ void initialize_bin_for_strictypes(AerospikeClient *self, as_error *err,

// Cleanup
Py_XDECREF(geo_data_py_str);
Py_XDECREF(geo_data);
}
else if (!strcmp(py_value->ob_type->tp_name, "aerospike.null")) {
((as_val *)&binop_bin->value)->type = AS_UNKNOWN;
Expand Down
12 changes: 9 additions & 3 deletions src/main/convert_expressions.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,15 @@ get_exp_val_from_pyval(AerospikeClient *self, as_static_pool *static_pool,
PyObject *py_parameter = PyUnicode_FromString("geo_data");
PyObject *py_data = PyObject_GenericGetAttr(py_obj, py_parameter);
Py_DECREF(py_parameter);
char *geo_value =
(char *)PyUnicode_AsUTF8(AerospikeGeospatial_DoDumps(py_data, err));
Py_DECREF(py_data);
PyObject *geospatial_dump = AerospikeGeospatial_DoDumps(py_data, err);
Py_XDECREF(py_data);
if (!geospatial_dump) {
PyErr_Clear();
return as_error_update(err, AEROSPIKE_ERR_CLIENT,
"Unable to call dumps function");
}
char *geo_value = (char *)PyUnicode_AsUTF8(geospatial_dump);

as_exp_entry tmp_entry = as_exp_geo(geo_value);
*new_entry = tmp_entry;
}
Expand Down
8 changes: 2 additions & 6 deletions src/main/geospatial/dumps.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ PyObject *AerospikeGeospatial_DoDumps(PyObject *geo_data, as_error *err)
json_module = PyImport_ImportModule("json");
}

if (!json_module) {
/* insert error handling here! and exit this function */
as_error_update(err, AEROSPIKE_ERR_CLIENT,
"Unable to load json module");
}
else {
if (json_module && geo_data) {
PyObject *py_funcname = PyUnicode_FromString("dumps");
initresult = PyObject_CallMethodObjArgs(json_module, py_funcname,
geo_data, NULL);
Expand Down Expand Up @@ -72,6 +67,7 @@ PyObject *AerospikeGeospatial_Dumps(AerospikeGeospatial *self, PyObject *args,

initresult = AerospikeGeospatial_DoDumps(self->geo_data, &err);
if (!initresult) {
PyErr_Clear();
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
"Unable to call dumps function");
goto CLEANUP;
Expand Down
5 changes: 2 additions & 3 deletions src/main/predicates.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ static PyObject *AerospikePredicates_GeoWithin_Radius(PyObject *self,
py_shape = AerospikeGeospatial_DoDumps(py_geo_object, &err);

if (!py_shape) {
PyErr_Clear();
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
"Unable to call dumps function");
goto CLEANUP;
Expand All @@ -236,7 +237,6 @@ static PyObject *AerospikePredicates_GeoWithin_Radius(PyObject *self,
"double type, bin of string type");
goto CLEANUP;
}
Py_CLEAR(py_geo_object);

ret_val = Py_BuildValue("iiOOOO", AS_PREDICATE_RANGE, AS_INDEX_GEO2DSPHERE,
py_bin, py_shape, Py_None, py_indexType);
Expand Down Expand Up @@ -319,12 +319,11 @@ static PyObject *AerospikePredicates_GeoContains_Point(PyObject *self,
py_list = Py_BuildValue("[OO]", py_lat, py_long);

PyDict_SetItemString(py_geo_object, "coordinates", py_list);
Py_CLEAR(py_list);

py_shape = AerospikeGeospatial_DoDumps(py_geo_object, &err);
Py_CLEAR(py_geo_object);

if (!py_shape) {
PyErr_Clear();
as_error_update(&err, AEROSPIKE_ERR_CLIENT,
"Unable to call dumps function");
goto CLEANUP;
Expand Down
Loading
Loading