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

workaround win32 crash (or error) on SetCommState #669

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

foldl
Copy link

@foldl foldl commented Oct 14, 2022

I believe there is a bug (a.k.a the crash "OSError: exception: stack overflow") in SetCommState.

Steps to trigger the crash

  1. Use some other tools to open a COM port where
    • a large buffer size (e.g. 102400) is configured in SetupComm,
    • set XonLim and XoffLim to (102400 / 4) in SetCommState
  2. Close the port;
  3. Use pyserial to open the port, or use mode command to reconfigure it.

Test Environment

  • JLink CDC COM;
  • Latest Windows 10/11.

Expected Behavior

Window may return an error code but not crash if it finds something strange.

Workaround

It seems unrealistic to wait MS to fix this. So here comes the workaround, which might also resolve #258 and #362:

Set XonLim and XoffLim according to buffer size configured in SetupComm.

Set `XonLim` and `XoffLim` according to buffer size configured in `SetupComm`.
@foldl
Copy link
Author

foldl commented May 16, 2023

A detailed analysis:

https://foldl.github.io/2022-10-18-chasing-a-win32-bug/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pyserial 3.4 with Python 2.17.13 under Windows 10
1 participant