fix metal uaf (#964)

This commit is contained in:
George Hotz
2023-06-09 21:28:06 -07:00
committed by GitHub
parent c0e558b77c
commit 2c324d0685
2 changed files with 18 additions and 1 deletions

17
test/external/external_metal_uaf.py vendored Normal file
View File

@@ -0,0 +1,17 @@
import weakref
import numpy as np
from tinygrad.tensor import Tensor, Device
Device.DEFAULT = "METAL"
if __name__ == "__main__":
t = Tensor.zeros(3).realize()
wt = weakref.ref(t.lazydata.realized)
n = t.numpy()
t += 1
n2 = t.numpy()
print(wt)
del t
print(wt)
print(n, n.base, n.base.base)
print(n2, n2.base, n2.base.base)
assert wt() is not None