The test case test_raiseMemError assumes that all structs have a NULL byte of length 1. However compact_struct_size allocate 2 or 4 bytes space for NULL bytes: (PyUnicode_GET_LENGTH(self) + 1) * PyUnicode_KIND(self). Note that it's (len(s) + 1) * char_size, not len(s) * char_size + 1. The bug introduces an off-by-one / off-by-three error that sometimes leads to failing test on WASI, because code does not raise a memory error.
The test case
test_raiseMemErrorassumes that all structs have a NULL byte of length 1. Howevercompact_struct_sizeallocate 2 or 4 bytes space for NULL bytes:(PyUnicode_GET_LENGTH(self) + 1) * PyUnicode_KIND(self). Note that it's(len(s) + 1) * char_size, notlen(s) * char_size + 1. The bug introduces an off-by-one / off-by-three error that sometimes leads to failing test on WASI, because code does not raise a memory error.