-
Notifications
You must be signed in to change notification settings - Fork 50
Add concurrent set_attr stress test for buffer safety #578
Copy link
Copy link
Open
Labels
area: dev-infra/testsTests/infra and contributor tooling: dev containers, build setup, PR template, repo housekeeping.Tests/infra and contributor tooling: dev containers, build setup, PR template, repo housekeeping.enhancementNew feature or requestNew feature or requesttriage doneIssues that are triaged by dev team and are in investigation.Issues that are triaged by dev team and are in investigation.
Metadata
Metadata
Assignees
Labels
area: dev-infra/testsTests/infra and contributor tooling: dev containers, build setup, PR template, repo housekeeping.Tests/infra and contributor tooling: dev containers, build setup, PR template, repo housekeeping.enhancementNew feature or requestNew feature or requesttriage doneIssues that are triaged by dev team and are in investigation.Issues that are triaged by dev team and are in investigation.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Context
PR #568 fixed a potential buffer race in
Connection::setAttribute()whereptrpointed into a member field (wstrStringBuffer/strBytesBuffer) while the GIL was released. Another thread callingset_attron the same connection could reallocate the buffer, leaving a dangling pointer for the ODBC driver.The fix (commit
05c6ca2c) copies to stack-local buffers before the GIL release, making the race structurally impossible.Requested Test
Add a cross-platform concurrent stress test that:
conn.set_attr(SQL_ATTR_CURRENT_CATALOG, ...)(or another string attribute) in a tight loop with alternating short and long values to force buffer reallocationThis serves as a regression guard — on the fixed code it should always pass, but it would catch any future refactoring that accidentally reverts to pointing into member fields.
Notes
wchar_t == SQLWCHAR, so no conversion copy was needed). macOS/Linux were accidentally safe due to theWStringToSQLWCHARconversion creating a stack-local vector.Related
connect()(issue Reopen Issue #491: SSH tunneling fails using paramiko+sshtunnel #565)