fix: assert message printing

- assert buffer has header that needs to be accounted for while parsing
the buffer and reading format strings. currentOffset in Printf Formatter
must not exceed size in header. The offset is relative to the beginning
of buffer, not the "begin" field in header

Resolves: NEO-8237

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2023-08-04 15:25:20 +00:00
committed by Compute-Runtime-Automation
parent 53e85728cd
commit c44b600ec7
4 changed files with 13 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ bool AssertHandler::checkAssert() const {
void AssertHandler::printMessage() const {
auto messageBuffer = ptrOffset(static_cast<uint8_t *>(assertBuffer->getUnderlyingBuffer()), offsetof(AssertBufferHeader, begin));
auto messageBuffer = static_cast<uint8_t *>(assertBuffer->getUnderlyingBuffer());
auto messageBufferSize = static_cast<uint32_t>(assertBuffer->getUnderlyingBufferSize());
NEO::PrintFormatter printfFormatter{
@@ -43,6 +43,8 @@ void AssertHandler::printMessage() const {
messageBufferSize,
false,
nullptr};
printfFormatter.setInitialOffset(offsetof(AssertBufferHeader, begin));
printfFormatter.printKernelOutput([](char *str) { printToStderr(str); });
}