Python Client - Segmentation fault upon MultiGet - version 2.0.3


#1

Hello,
I ran the following simple code on the python client version 2.0.3 and received a segmentation fault when the function exists. This only happens on version 2.0.3 (version 2.0.2 works fine). Below the code sinppet, is the gdb backtrace

import couchbase
id_format = 'test_counter_{}'
ids = list()
for num in range(60000):
ids.append(id_format.format(num))

def get_ids(ids):
cb = couchbase.bucket.Bucket(‘couchbase://localhost/statistics’)
start=time.time()
cb_result=cb.get_multi(ids, quiet=True)
end=time.time()
print(‘len result = {}’.format(len(cb_result)))

get_ids(ids)

BACKTRACE:

#0 OperationResult_dealloc (self=0x7ffff31b2a70) at src/opresult.c:38
#1 ValueResult_dealloc (self=0x7ffff31b2a70) at src/opresult.c:45
#2 0x00007ffff79d2caf in free_keys_object (keys=0x94a3e0) at Objects/dictobject.c:369
#3 0x00007ffff79d601c in dict_dealloc (mp=0x7ffff61ed800) at Objects/dictobject.c:1391
#4 0x00007ffff79bf432 in frame_dealloc (f=0x7ffff64bc630) at Objects/frameobject.c:429
#5 0x00007ffff7a61833 in fast_function (nk=, na=, n=, pp_stack=0x7fffffffe198,
func=0x7ffff6e7e268) at Python/ceval.c:4326
#6 call_function (oparg=, pp_stack=0x7fffffffe198) at Python/ceval.c:4252
#7 PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:2829
#8 0x00007ffff7a62271 in PyEval_EvalCodeEx (_co=, globals=, locals=,
args=, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0)
at Python/ceval.c:3578
#9 0x00007ffff7a6233b in PyEval_EvalCode (co=, globals=, locals=)
at Python/ceval.c:773
#10 0x00007ffff7a82970 in run_mod (arena=0x60e5c0, flags=0x7fffffffe4b0, locals=0x7ffff6ee3ec8, globals=0x7ffff6ee3ec8,
filename=0x7ffff6de5db0, mod=0x6cae90) at Python/pythonrun.c:2180
#11 PyRun_FileExFlags (fp=0x6544c0, filename_str=, start=, globals=0x7ffff6ee3ec8,
locals=0x7ffff6ee3ec8, closeit=, flags=0x7fffffffe4b0) at Python/pythonrun.c:2133
#12 0x00007ffff7a85854 in PyRun_SimpleFileExFlags (fp=0x6544c0, filename=, closeit=1, flags=0x7fffffffe4b0)
at Python/pythonrun.c:1606
#13 0x00007ffff7a9fae6 in run_file (p_cf=0x7fffffffe4b0, filename=0x6032d0 L"/tmp/test.py", fp=0x6544c0) at Modules/main.c:319
#14 Py_Main (argc=, argv=) at Modules/main.c:752
#15 0x0000000000400acd in main (argc=2, argv=0x7fffffffe628) at ./Modules/python.c:69


#2

Thanks for the report. I have no idea why this wasn’t picked up by any of the tests, since this the cause is fairly serious and pretty silly. The fix…

diff --git a/src/opresult.c b/src/opresult.c
index 3f9e113..03796f6 100644
--- a/src/opresult.c
+++ b/src/opresult.c
@@ -34,8 +34,8 @@ ValueResult_value(pycbc_ValueResult *self, void *closure)
 static void
 OperationResult_dealloc(pycbc_OperationResult *self)
 {
-    pycbc_Result_dealloc((pycbc_Result*)self);
     Py_CLEAR(self->mutinfo);
+    pycbc_Result_dealloc((pycbc_Result*)self);
 }
 
 static void