You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split PGM into 3 different section discussing the allocation, deallocation, and memory usage.
Add new information regarding left/right allignment that was recently added.
* docs/Deep Dive/Libpas/Internals.md
Copy file name to clipboardExpand all lines: docs/Deep Dive/Libpas/Internals.md
+23-17Lines changed: 23 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1215,23 +1215,29 @@ page header tables even for the small bitfit page config.
1215
1215
1216
1216
### Probabilistic Guard Malloc
1217
1217
1218
-
Probabilistic Guard Malloc (PGM) is a new allocator designed to catch use after free attempts and out of bounds accesses.
1219
-
It behaves similarly to AddressSanitizer (ASAN), but aims to have minimal runtime overhead.
1220
-
1221
-
The design of PGM is quite simple. Each time an allocation is performed an additional guard page is added above and below the newly
1222
-
allocated page(s). An allocation may span multiple pages. When a deallocation is performed, the page(s) allocated will be protected
1223
-
using mprotect to ensure that any use after frees will trigger a crash. Virtual memory addresses are never reused, so we will never run
1224
-
into a case where object 1 is freed, object 2 is allocated over the same address space, and object 1 then accesses the memory address
1225
-
space of now object 2.
1226
-
1227
-
PGM does add notable memory overhead. Each allocation, no matter the size, adds an additional 2 guard pages (8KB for X86_64 and 32KB
1228
-
for ARM64). In addition, there may be free memory left over in the page(s) allocated for the user. This memory may not be used by any
1229
-
other allocation.
1230
-
1231
-
We added limits on virtual memory and wasted memory to help limit the memory impact on the overall system. Virtual memory for this
1232
-
allocator is limited to 1GB. Wasted memory, which is the unused memory in the page(s) allocated by the user, is limited to 1MB.
1233
-
These overall limits should ensure that the memory impact on the system is minimal, while helping to tackle the problems of catching
1234
-
use after frees and out of bounds accesses.
1218
+
Probabilistic Guard Malloc (PGM) is a new allocator designed to catch use after free attempts and out of bounds accesses.
1219
+
It behaves similarly to AddressSanitizer (ASAN), but aims to have minimal runtime overhead.
1220
+
1221
+
#### Allocation
1222
+
1223
+
Each time an allocation is performed an additional guard page is added above and below the newly
1224
+
allocated page(s). An allocation may span multiple pages. Allocations are either left or right aligned at random, which
1225
+
ensures the catching of both overflow and underflow errors.
1226
+
1227
+
#### Deallocation
1228
+
1229
+
When a deallocation is performed, the page(s) allocated will be protected using `mprotect` to ensure that any use after frees will trigger a crash. Virtual memory addresses are never reused, so we will never run into a case where object 1 is freed, object 2 is allocated over the same address space, and object 1 then accesses the memory address space of now object 2.
1230
+
1231
+
#### Memory Usage
1232
+
1233
+
PGM does add notable memory overhead. Each allocation, no matter the size, adds an additional 2 guard pages (8KB for X86_64 and 32KB
1234
+
for ARM64). In addition, there may be free memory left over in the page(s) allocated for the user. This memory may not be used by any
1235
+
other allocation.
1236
+
1237
+
We added limits on virtual memory and wasted memory to help limit the memory impact on the overall system. Virtual memory for this
1238
+
allocator is limited to 1GB. Wasted memory, which is the unused memory in the page(s) allocated by the user, is limited to 1MB.
1239
+
These overall limits should ensure that the memory impact on the system is minimal, while helping to tackle the problems of catching
0 commit comments