Skip to content

Add concurrent set_attr stress test for buffer safety #578

@saurabh500

Description

@saurabh500

Context

PR #568 fixed a potential buffer race in Connection::setAttribute() where ptr pointed into a member field (wstrStringBuffer / strBytesBuffer) while the GIL was released. Another thread calling set_attr on 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:

  1. Shares a single connection across N threads
  2. Each thread calls conn.set_attr(SQL_ATTR_CURRENT_CATALOG, ...) (or another string attribute) in a tight loop with alternating short and long values to force buffer reallocation
  3. Asserts no crashes, no ODBC errors with garbled attribute values

This 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

Related

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesttriage neededFor new issues, not triaged yet.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions