Here are (failing) test cases:
Python 2.5 (r25:51908, Oct 4 2006, 18:25:28)
[GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> dlopen('libc.so.6')
182896775816
>>> dlclose(_)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: signed integer is greater than maximum
>>> dlsym(_, 'printf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: signed integer is greater than maximum
>>> call_function(_, ()) # pretend that _ is a function pointer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: signed integer is greater than maximum
>>> call_cdeclfunction(_, ()) # pretend that _ is a function pointer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: signed integer is greater than maximum
With the patch:
>>> from _ctypes import *
>>> dlopen('libc.so.6')
182894214624
>>> dlclose(_)
I don't know how to meaningfully exercise call_function and call_cdeclfunction to trigger the bug because in the default (small memory) model on AMD64 function pointers always fit into 32 bits. Maybe a pseudo-function pointer created by an ffi callback can be used for this purpose.
I am not sure where these test belong in the testsuit. Maybe in ctypes/test/test_loading.py?
|