Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

Jason Qian jqian at tibco.com
Mon Jan 22 16:00:01 EST 2018


Hello!

  I am using ctypes on Windows to interface with a dll  and it works fine
on Linux and windows 32-bit python.  But, when using 64-bit python, we got
error "exception: access violation writing 0xFFFFFFFF99222A60".

    Checking our server, it seems work without any problem. but the python
gives an error and stop the application.

-- c --
class myPythonAPI
{
public:
myPythonAPI();
int createService(const char* serviceName){ /* run our application*/};
}
extern "C" {
__declspec(dllexport) myPythonAPI* loadInstance(){ return new
myPythonAPI(); }
__declspec(dllexport) int createService(myPythonAPI* obj, const char*
serviceName) { eturn obj->createService(serviceName);
};

-- python --
from ctypes import *
lib = cdll.LoadLibrary('xxxxxxx.dll')

lib.createService.argtypes=[c_int,ctypes.c_char_p]
lib.createService.restype=ctypes.c_int

class myDriver(object):
def init(self):
self.obj = lib.loadInstance()

def create_services(self,servicename):
    result=lib.createService(self.obj,servicename)
    return result

driver=myDriver()
driver.create_services(b"myExample")

Thanks for the help
Jason



More information about the Python-list mailing list