[XLA:GPU] Fix invalid memory dereference in GpuCudaMallocAsyncAllocator.
The issue is this:
On line 252, the code compares *pool_item_ == pool_ and ASAN complains about stack-use-after-return. This means that *pool_item_ is an invalid dereference.
pool_item is the address of a GpuCudaMallocAsyncAllocator::pool_ field that was inserted in the global all_pools_ in a previous execution of the GpuCudaMallocAsyncAllocator constructor.
However, after that previous GpuCudaMallocAsyncAllocator object is no longer live, all addresses of its fields are now invalid, leading the invalid dereference.
The solution is to not store pointers and so not need any dereference. The underlying type is anyway a pointer so we can store and compare it directly.
[XLA:GPU] Fix invalid memory dereference in
GpuCudaMallocAsyncAllocator
.The issue is this:
*pool_item_ == pool_
and ASAN complains aboutstack-use-after-return
. This means that*pool_item_
is an invalid dereference.pool_item
is the address of aGpuCudaMallocAsyncAllocator::pool_
field that was inserted in the globalall_pools_
in a previous execution of theGpuCudaMallocAsyncAllocator
constructor.GpuCudaMallocAsyncAllocator
object is no longer live, all addresses of its fields are now invalid, leading the invalid dereference.The solution is to not store pointers and so not need any dereference. The underlying type is anyway a pointer so we can store and compare it directly.