mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-29 03:00:14 -04:00
fix metal uaf (#964)
This commit is contained in:
17
test/external/external_metal_uaf.py
vendored
Normal file
17
test/external/external_metal_uaf.py
vendored
Normal 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
|
||||
Reference in New Issue
Block a user