gh-151284: Fix test_capi on UBSan#151286
Conversation
Remove two checks relying on undefined behavior in test_fromwidechar() of test_capi. Enable test_capi in GitHub Action "Reusable Sanitizer".
PyObject *
PyUnicode_FromWideChar(const wchar_t *u, Py_ssize_t size)
{
...
if (find_maxchar_surrogates(u, u + size,
&maxchar, &num_surrogates) == -1)
return NULL;
...
}
|
|
@serhiy-storchaka: Would you mind to review this change? |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
I think we should left commented out calls with an explanatory comment, like for crashes. It indicates that we did not miss these cases, so they will not be reintroduced.
I added this code at the end of the function. Is it what you mean? # The following tests are skipped since they rely on undefined behavior
#self.assertRaises(MemoryError, fromwidechar, b'', PY_SSIZE_T_MAX)
#self.assertRaises(SystemError, fromwidechar, b'\0'*SIZEOF_WCHAR_T, PY_SSIZE_T_MIN) |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-151323 is a backport of this pull request to the 3.15 branch. |
|
GH-151324 is a backport of this pull request to the 3.14 branch. |
|
GH-151325 is a backport of this pull request to the 3.13 branch. |
|
Merged. Thanks for the review @serhiy-storchaka. |
Remove two checks relying on undefined behavior in test_fromwidechar() of test_capi.
Enable test_capi in GitHub Action "Reusable Sanitizer".