robotology / yarp

YARP - Yet Another Robot Platform

Home Page:http://www.yarp.it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python bindings: detected a memory leak of type 'yarp::os::Type *'

valegagge opened this issue · comments

Describe the bug
I'm trying to set a reader to a yarp port. When I run the code this string comes out
swig/python detected a memory leak of type 'yarp::os::Type *', no destructor found.

To Reproduce
You can use this code:

import yarp

class DataProcessor(yarp.PortReader):

    def read(self,connection):
        #print("in DataProcessor.read")
        if not(connection.isValid()):
            print("testOne: connection not valid...closing")
            return False
        bin = yarp.Bottle()
        #bout = yarp.Bottle()
        print("Trying to read from connection")
        ok = bin.read(connection)
        if not(ok):
            print("testOne: failed to read input")
            return False
       
        print("Received [%s]"%bin.toString())
        return True
        
 

def main():
    yarp.Network.init()

    if not yarp.Network.checkNetwork():
        print("yarpserver is not running")
        quit()

    myport = yarp.Port()
    dataProc = DataProcessor()
    myport.setReader(dataProc)
    myport.open("/testOne/cmd:i")

if __name__ == "__main__":
    main()

Configuration (please complete the following information):

  • OS: Ubuntu 20.04.4 LTS
  • yarp version: 3.7.2+14-20221007.2+gita00b1e6e7
  • compiler: -

Help requested...

Possibly related, I also noticed a missing destructor issue in Python bindings generated for downstream YARP projects: #2757 (look for %include "yarp/os/Type.h" // avoid SWIG memory leaks due to a missing destructor).