New submission from Taekab Park <sh4...@naver.com>:

It seems like ctypes code makes truncated pointer values in x64(access 
violations)

windows10 x64
options : __cdecl(/Gd)
tested : python(x64) 3.2, 3.4, 3.6, 3.9 
dll build with vc++2015 


The test code is simple.
Simply loaded TestDll and called function and checked return void* value.

result
actual void* : 0x00007FFDA4322018  <-> python void* : 0xFFFFFFFFA4322018

== C code ==
void* GetPointer();
SetPointer(void* value);
INT64 GetPointer1();
void SetPointer1(INT64 obj);

== python == 
import ctypes

print(ctypes.sizeof(ctypes.c_void_p))
_testdll = ctypes.CDLL(r"TestDll.dll")

def tohex(val, nbits):
        return hex((val + (1 << nbits)) % (1 << nbits))

result = _testdll.GetPointer()
print(tohex(result, 64))
_testdll.SetPointer(result)

result = _testdll.GetPointer1()
print(tohex(result, 64))
_testdll.SetPointer1(result)

----------
components: ctypes
files: example.zip
messages: 380676
nosy: sh4dow
priority: normal
severity: normal
status: open
title: It seems like ctypes code makes truncated pointer values in x64(access 
violations)
type: crash
versions: Python 3.6, Python 3.9
Added file: https://bugs.python.org/file49589/example.zip

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42311>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to