Alter FailFast behaviour of memcpy (#526)

This commit changes the codegen for error messages for failed memcpys.
This no longer generates a stack frame and correctly tail calls the
error messages generator.

It also turns the error messages on in Release builds.  This will lead
to better adoption experience.
This commit is contained in:
Matthew Parkinson
2022-05-19 14:20:45 +01:00
committed by GitHub
parent 87d71cce21
commit c445de8eb4
3 changed files with 66 additions and 69 deletions

View File

@@ -90,7 +90,12 @@ void memcpy_unchecked(void* dst, const void* src, size_t size)
NOINLINE
void memcpy_platform_checked(void* dst, const void* src, size_t size)
{
check_bounds(dst, size, "");
if (SNMALLOC_UNLIKELY(!check_bounds(dst, size)))
{
report_fatal_bounds_error(dst, size, "");
return;
}
memcpy(dst, src, size);
}