Closed mattip closed 11 months ago
The test_charptr.py
tests crash on PyPy and on CPython if there is no mem protection. I don't think the exact error message is important or even guaranteed to be reproducible since the code is writing to arbitrary memory.
The
test_charptr.py
tests crash on PyPy and on CPython if there is no mem protection. I don't think the exact error message is important or even guaranteed to be reproducible since the code is writing to arbitrary memory.
They crash? I think that's unexpected. Do you know why?
If we don't have mem protection, we write some carefully picked bytes into the buffer (i.e. the poison which is char poison[] = {0xBA, 0xD0, 0xDA, 0x7A};
) that will prevent any useful usage in a unicode object.
I think PyPy does not like the random unicode string. On the hpy-0.0.4 branch, PyPy exits with 1 and prints
b'RPython traceback:
File "pypy_interpreter.c", line 48519, in BuiltinCodePassThroughArguments1_funcrun_obj
File "pypy_module__hpy_universal.c", line 18123, in W_ExtensionFunction_d_descr_call
File "pypy_module__hpy_universal.c", line 18936, in W_ExtensionFunction_d_call_noargs
File "pypy_module__hpy_universal.c", line 49901, in ctx_HPyUnicode_FromString__star_2
File "pypy_module__hpy_universal.c", line 59473, in HPyUnicode_FromString
File "pypy_module__hpy_universal_1.c", line 17855, in _maybe_utf8_to_w
File "rpython_rlib.c", line 5324, in check_utf8
Traceback (most recent call last):
File "<string>", line 1, in <module>
SystemError: unexpected internal exception (please report a bug): <CheckError object at 0x7f2e5210f640>; internal traceback was dumped to stderr'
CPython exits with -11 and prints b''
.
Closing in favor of #455
The changes are
on_invalid_handle
hook in debug mode, since setting the hook will fail on non-cpython in accordance with this comment, which should be in a more permanent placeSUPPORTS_MEM_PROTECTION
checks to PyPy