diff options
author | Lars Knoll <lars.knoll@digia.com> | 2017-04-21 11:57:22 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-04-21 10:12:28 +0000 |
commit | 3d05a10e40d4349b01e292dbc297036f8de38049 (patch) | |
tree | 5b05c0369d3e3fbe0a28ea77b9b9f8ac420a2eeb /src | |
parent | 85eaae8b4c7e3cf0cf7eb69e3ba0affb820ac08e (diff) |
Fix GC corruption on macOS and possibly some other OSes
Marking mmap'ed memory as unneeded, leads to it being zeroed out on
both Linux and Windows. Unfortunately that behavior is not defined by
POSIX, so BSD based OSes (and possible others as well) do not do this.
We do however rely on getting zeroed out memory whenever we allocate a
new Chunk for the garbage collector. To work around this, zero out memory
we deallocate on those platforms.
Task-number: QTBUG-59278
Task-number: QTBUG-59977
Change-Id: Idde812db8537b63b9e9df7de41620ce0df09b6de
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 27adfcb517..88912a6678 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -161,6 +161,13 @@ struct MemorySegment { size_t pageSize = WTF::pageSize(); size = (size + pageSize - 1) & ~(pageSize - 1); +#if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN) + // Linux and Windows zero out pages that have been decommitted and get committed again. + // unfortunately that's not true on other OSes (e.g. BSD based ones), so zero out the + // memory before decommit, so that we can be sure that all chunks we allocate will be + // zero initialized. + memset(chunk, 0, size); +#endif pageReservation.decommit(chunk, size); } |