← 输入框|github.com|刷新
Skip to content

ctypes "ValueError: NULL pointer access" on Win7 x64 #53512

Closed

Description

@ghazel
mannequin
BPO 9266
Nosy @theller, @mattip
Files
  • ctypes_test.zip
  • ctypes_win64.diff: one-liner fix
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/theller'
    closed_at = <Date 2014-05-14.10:01:12.252>
    created_at = <Date 2010-07-15.12:55:48.763>
    labels = ['ctypes', 'type-crash']
    title = 'ctypes "ValueError: NULL pointer access" on Win7 x64'
    updated_at = <Date 2014-05-14.10:01:12.251>
    user = 'https://bugs.python.org/ghazel'

    bugs.python.org fields:

    activity = <Date 2014-05-14.10:01:12.251>
    actor = 'berker.peksag'
    assignee = 'theller'
    closed = True
    closed_date = <Date 2014-05-14.10:01:12.252>
    closer = 'berker.peksag'
    components = ['ctypes']
    creation = <Date 2010-07-15.12:55:48.763>
    creator = 'ghazel'
    dependencies = []
    files = ['18023', '20529']
    hgrepos = []
    issue_num = 9266
    keywords = ['patch']
    message_count = 5.0
    messages = ['110362', '110412', '117928', '127094', '218496']
    nosy_count = 5.0
    nosy_names = ['theller', 'ghazel', 'ocean-city', 'stan.mihai', 'mattip']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue9266'
    versions = ['Python 3.1', 'Python 2.7']

    Activity

    1. ghazel commented on Jul 15, 2010

      ghazelmannequin
      MannequinAuthor

      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.

    2. ghazel commented on Jul 16, 2010

      ghazelmannequin
      MannequinAuthor

      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!

    3. ocean-city commented on Oct 3, 2010

      ocean-citymannequin
      Mannequin

      Probably this issue is duplicate of bpo-9884.

    4. stanmihai commented on Jan 26, 2011

      stanmihaimannequin
      Mannequin

      The problem was an uninitialized variable. Attached is the patch that fixes it.

    5. mattip commented on May 14, 2014

      @mattip
      Contributor

      This was fixed with changeset 8fa73a0885c9 in Jan 2011, probably should be closed

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    topic-ctypestype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions