Skip to content

Conversation

@geppi
Copy link
Collaborator

@geppi geppi commented Jul 20, 2025

There is a serious bug in the code that creates a new COM Record instance.

It kicks in when a tuple of com_record instances is created from a SAFEARRAY of COM Records.
The bug causes the data of all com_record tuple elements to be stored in the same RecordBuffer segment, i.e. the segment dedicated to the first com_record tuple element.

I'm sorry, this was my mistake in the implementation of PR #2437 and will be fixed by this PR.

When a tuple of com_record instances was created from a
SAFEARRAY of COM Records, the data of all com_record tuple elements
was always stored in the RecordBuffer segment of the first
com_record tuple element.
@geppi
Copy link
Collaborator Author

geppi commented Jul 20, 2025

Something seems to be broken with the CI workflow:

======================================================================
ERROR: test_creddelete (test_win32cred.TestCredFunctions.test_creddelete)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\pywin32\pywin32\win32\test\test_win32cred.py", line 44, in test_creddelete
    self.assertFalse(self.is_dummy_cred())
                     ^^^^^^^^^^^^^^^^^^^^
  File "D:\a\pywin32\pywin32\win32\test\test_win32cred.py", line 33, in is_dummy_cred
    for e in win32cred.CredEnumerate()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (1168, 'CredEnumerate', 'Element not found.')

@geppi geppi requested a review from mhammond July 20, 2025 16:45
@geppi
Copy link
Collaborator Author

geppi commented Aug 27, 2025

It is very important to merge this before the next release, please.
The bug can cause data corruption that might stay unrecognised and lead to surprises because currently:

> a: tuple[RECORD_T, ...] = some_COM_method_that_returns_a_SAFEARRAY_of_RECORD_T_instances()
> a[0].attribute == a[1].attribute
  True

> a[0] is a[1]
  False

> a[0].attribute == other_value
  False

> a[0].attribute = other_value
> a[0].attribute == a[1].attribute
  True

Ooops.

Copy link
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! It would be great to get a test in a later PR if possible

@mhammond mhammond merged commit a84f673 into mhammond:main Aug 27, 2025
30 checks passed
@geppi geppi deleted the rec_buf_bug branch September 20, 2025 06:41
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.

2 participants