Set allocated memory to 0 on VxWorks

When VxWorks is configured with RTP_MEM_FILL false for performance
reasons, then it is not filling the allocated memory to 0, causing
the QML engine to crash, because it is expecting that it is filled
with 0s. This change handles this scenario by calling memset 0 on
the allocated memory. Qt needs to be configured with
QT_RTP_MEM_FILL define.

Task-number: QTBUG-133305
Pick-to: 6.8 6.9
Change-Id: I885c3cad7d81a11b8a0c125ddc098751b9643392
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Karim Pinter 2025-02-07 16:03:48 +02:00
parent 567ece7681
commit 0856267750
1 changed files with 5 additions and 0 deletions

View File

@ -185,6 +185,11 @@ void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bo
#endif
CRASH();
}
#if OS(VXWORKS) && defined(QT_RTP_MEM_FILL) && QT_RTP_MEM_FILL
// page allocator expects mmap'ed memory to be zero'ed
memset(result, 0, bytes);
#endif
if (result && includesGuardPages) {
// We use mmap to remap the guardpages rather than using mprotect as
// mprotect results in multiple references to the code region. This