m0spiel: fix sigsegv crash on
Specify explicit return type of c_void_p for __malloc()
to avoid pointer conversion to int32 when passing them
as arguments to Motr routines.
@@ -188,7 +188,7 @@ def call(func, *args):
class SpielWrapper:
def __init__(self, motr):
self.motr = CDLL(motr)
- self.motr.malloc.restype = c_void_p
+ self.motr.m0_alloc.restype = c_void_p
self.signal_nr = None
self.signal_cb = None
@@ -603,11 +603,9 @@ class SpielWrapper:
reqh_args.rhia_fid = pointer(Fid(0x7200000000000001, 5)) # process-5
reqh_args.rhia_mdstore = 1 # dummy value
call(self.motr.m0_reqh_init, reqh, byref(reqh_args))
- self.__free(reqh_args)
self.motr.m0_reqh_start(reqh)
rms = self.__malloc(m0_reqh_service__size())
- rms_p = cast(rms, c_void_p)
- call(self.motr.m0_reqh_service_setup, rms_p, self.motr.m0_rms_type,
+ call(self.motr.m0_reqh_service_setup, rms, self.motr.m0_rms_type,
reqh, None, byref(spiel_rms_fid))
self.reqh = reqh
@@ -640,12 +638,11 @@ class SpielWrapper:
self.spiel = spiel
def __malloc(self, size):
- ptr = self.motr.malloc(size) # XXX Why don't we use m0_alloc()?
- memset(ptr, 0, size)
- return ptr
+ ptr = self.motr.m0_alloc(size)
+ return cast(ptr, c_void_p)
def __free(self, ptr):
- self.motr.free(ptr)
+ self.motr.m0_free(ptr)
class SpielTool:
