Repository navigation
Update VT_ARRAY | VT_RECORD tests. - #982
Conversation
- Define `_SafeArrayGetRecordInfo` at module level using c_void_p in argtypes instead of `POINTER(IRecordInfo)`, eliminating the need for local import. - Use byref for result parameter following surrounding code style. - Add docstring and type ignore comment for return value.
Since commit 0681ffe, unpacking VT_ARRAYs containing VT_RECORDs no longer raises `KeyError('36')`. Update the characterization tests for `WrapBstrRecord`, `WrapValueRecord`, and `ReverseValueRecords` to verify the expected return values on the normal path instead of expecting a `KeyError`.
This test uses `faulthandler` and `multiprocessing` to run the test in a separate process.
The test `call_reverse_bstr_records` was an existing test. This change converts it to a characterization test. It captures and verifies the crash without breaking the whole test suite. The test probably crashes because of a double-free bug. Root cause (hypothesis): - The `VARIANT` has a `SAFEARRAY`. This `SAFEARRAY` probably shares the same `BSTR` pointer as `lp`. - After the COM call returns, `VariantClear` runs. `VariantClear` probably frees that `BSTR`. - Then Python runs `del lp`. This probably tries to free the same `BSTR` again. - This probably causes a double-free and heap corruption.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## up1_followup_104 #982 +/- ##
===================================================
Coverage ? 90.72%
===================================================
Files ? 147
Lines ? 15344
Branches ? 0
===================================================
Hits ? 13921
Misses ? 1423
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
While I was working on this, Python 3.15 crashed. So I wrote a test to capture the crash. I was surprised by the CI result. This means #104 may have worked as it was, if it had been merged back then. This is a delicate memory issue. I think some changes inside Python are related, but I don't fully understand it yet. Anyway, in the next PR, I will make the production code work as intended on every supported Python version. |
Updated to handle different Python versions.
Since `LP_SAFEARRAY` is also `_Pointer[tagSAFEARRAY]`, `_Pointer[tagSAFEARRAY] | LP_SAFEARRAY` was redundant.
83d03d0 to
893f402
Compare
Related to #63
The fix itself will be done in a separate PR.