File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 13
13
using namespace clang ;
14
14
using namespace clang ::interp;
15
15
16
+ // FIXME: There is a peculiar problem with the way we track pointers
17
+ // to blocks and the way we allocate dynamic memory.
18
+ //
19
+ // When we have code like this:
20
+ // while (true) {
21
+ // char *buffer = new char[1024];
22
+ // delete[] buffer;
23
+ // }
24
+ //
25
+ // We have a local variable 'buffer' pointing to the heap allocated memory.
26
+ // When deallocating the memory via delete[], that local variable still
27
+ // points to the memory, which means we will create a DeadBlock for it and move
28
+ // it over to that block, essentially duplicating the allocation. Moving
29
+ // the data is also slow.
30
+ //
31
+ // However, when we actually try to access the allocation after it has been
32
+ // freed, we need the block to still exist (alive or dead) so we can tell
33
+ // that it's a dynamic allocation.
34
+
16
35
DynamicAllocator::~DynamicAllocator () { cleanup (); }
17
36
18
37
void DynamicAllocator::cleanup () {
You can’t perform that action at this time.
0 commit comments