Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32Serial.read coding error for non-blocking read #55289

Closed
tmtopka mannequin opened this issue Jan 31, 2011 · 2 comments
Closed

Win32Serial.read coding error for non-blocking read #55289

tmtopka mannequin opened this issue Jan 31, 2011 · 2 comments
Labels
extension-modules C modules in the Modules dir OS-windows type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@tmtopka
Copy link
Mannequin

tmtopka mannequin commented Jan 31, 2011

BPO 11080
Nosy @briancurtin
Files
  • serialwin32.py: Package pyserial driver for 32-bit Windows platform
  • 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 = None
    closed_at = <Date 2011-01-31.16:59:52.662>
    created_at = <Date 2011-01-31.16:58:55.236>
    labels = ['extension-modules', 'invalid', 'OS-windows', 'type-crash']
    title = 'Win32Serial.read coding error for non-blocking read'
    updated_at = <Date 2011-01-31.16:59:52.661>
    user = 'https://bugs.python.org/tmtopka'

    bugs.python.org fields:

    activity = <Date 2011-01-31.16:59:52.661>
    actor = 'brian.curtin'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-01-31.16:59:52.662>
    closer = 'brian.curtin'
    components = ['Extension Modules', 'Windows']
    creation = <Date 2011-01-31.16:58:55.236>
    creator = 'tmtopka'
    dependencies = []
    files = ['20628']
    hgrepos = []
    issue_num = 11080
    keywords = []
    message_count = 2.0
    messages = ['127619', '127620']
    nosy_count = 2.0
    nosy_names = ['brian.curtin', 'tmtopka']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue11080'
    versions = ['Python 2.6', '3rd party']

    @tmtopka
    Copy link
    Mannequin Author

    tmtopka mannequin commented Jan 31, 2011

    Attempting to read a fixed amount of data when the serial port is configured for non-blocking reads (i.e. self.timeout == 0) will occasionally throw an invalid memory access exception, due to an error in the following code:

    ### pyserial-2.5-rc2 serialWin32.py Line 219
                if self.timeout == 0:
                    n = min(comstat.cbInQue, size)
                    if n > 0:
                        buf = ctypes.create_string_buffer(n)
                        rc = win32.DWORD()
                        err = win32.ReadFile(self.hComPort, buf, size, ctypes.byref(rc), ctypes.byref(self._overlappedRead))

    The buffer length passed to win32.ReadFile should be 'n', not 'size'. This may not have been noticed since it is timing dependent: only if additional input is enqueued inbetween accessing the input queue length and the ReadFile call will the inappropriate invalid memory access exception be raised when 'size' is greater than 'n'.

    @tmtopka tmtopka mannequin added extension-modules C modules in the Modules dir OS-windows type-crash A hard crash of the interpreter, possibly with a core dump labels Jan 31, 2011
    @briancurtin
    Copy link
    Member

    You should contact pyserial.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir OS-windows type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant