This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年07月15日 12:55 by ghazel, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| ctypes_test.zip | ghazel, 2010年07月16日 04:29 | |||
| ctypes_win64.diff | stan.mihai, 2011年01月26日 09:16 | one-liner fix | review | |
| Messages (5) | |||
|---|---|---|---|
| msg110362 - (view) | Author: Greg Hazel (ghazel) | Date: 2010年07月15日 12:55 | |
ctypes on Windows on a 64bit Python installation gets a NULL pointer access where one is not expected.
To reproduce the problem, run make.bat then "python ctypes_test.py"
Failure output looks like this:
Three! 1 2 <__main__.LP_Some object at 0x000000000209C4C8>
<__main__.Some object at 0x000000000209C548>
91
Four! 1 2 3 <__main__.LP_Some object at 0x000000000209C4C8>
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 291, in 'calling callback function'
File "ctypes_test.py", line 21, in fourprinter
print(to.contents)
ValueError: NULL pointer access
Otherwise, successful output looks something like:
Three! 1 2 <ctypes.LP_Some object at 0x2acc9482aed0>
<__main__.Some object at 0x2acc9482ae50>
91
Four! 1 2 3 <ctypes.LP_Some object at 0x2acc9482aed0>
<__main__.Some object at 0x2acc9482ae50>
91
Environments exhibiting this problem:
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.architecture()
('64bit', 'WindowsPE')
Python 3.1.2 (r312:79149, Mar 20 2010, 22:55:39) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.architecture()
('64bit', 'WindowsPE')
Environments NOT exhibiting the problem:
Python 2.4.3 (#1, Sep 3 2009, 15:37:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.architecture()
('64bit', 'ELF')
Also Windows on a 32bit architecture seems unaffected.
|
|||
| msg110412 - (view) | Author: Greg Hazel (ghazel) | Date: 2010年07月16日 04:29 | |
Ok, this issue is worse, and much easier to reproduce, than I thought. Here is an updated ctypes_test.zip with a repro using only integers and callbacks.
Correct output:
('three', (1, 2, 3))
('four', (1, 2, 3, 4))
('five', (1, 2, 3, 4, 5))
Incorrect output:
('three', (1, 2, 3))
('four', (1, 2, 3, 0))
('five', (1, 2, 3, 0, 5))
I built Python 2.7 from source with MSVC 9. This is not reproducible in Debug mode, or Win32 Release mode. It only happens in x64 Release mode.
One very interesting discovery is that if I set these options:
Optimization: Disabled (/Od)
Enable Instrinsic Functions: No
the error does not occur!
|
|||
| msg117928 - (view) | Author: Hirokazu Yamamoto (ocean-city) * (Python committer) | Date: 2010年10月03日 19:34 | |
Probably this issue is duplicate of #9884. |
|||
| msg127094 - (view) | Author: stan mihai (stan.mihai) | Date: 2011年01月26日 09:16 | |
The problem was an uninitialized variable. Attached is the patch that fixes it. |
|||
| msg218496 - (view) | Author: mattip (mattip) * | Date: 2014年05月14日 01:04 | |
This was fixed with changeset 8fa73a0885c9 in Jan 2011, probably should be closed |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:03 | admin | set | github: 53512 |
| 2014年05月14日 10:01:12 | berker.peksag | set | status: open -> closed resolution: out of date stage: resolved |
| 2014年05月14日 01:04:28 | mattip | set | nosy:
+ mattip messages: + msg218496 |
| 2011年01月26日 09:16:42 | stan.mihai | set | files:
+ ctypes_win64.diff nosy: + stan.mihai messages: + msg127094 keywords: + patch |
| 2010年10月03日 19:34:44 | ocean-city | set | nosy:
+ ocean-city messages: + msg117928 |
| 2010年07月16日 04:29:06 | ghazel | set | files:
+ ctypes_test.zip messages: + msg110412 |
| 2010年07月16日 04:15:33 | ghazel | set | files: - ctypes_test.zip |
| 2010年07月15日 12:55:48 | ghazel | create | |