Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Use-after-Free in qembeddingbag_byte_prepack_out (pytorch#84750)
When FBGEMM is not used (either manually disabled or on platforms such as POWER where it isn't supported at all) the fallback code requests a `data_ptr<float>` on a `Tensor` object returned by `to(ScalarType::Float)` in the same line. This object will be destroyed at the end of the line leading to a dangling pointer. On some platforms this manifests in wrong results being returned as the memory gets overwritten. On other platforms anything may happen due to this being undefined behavior, although most likely it will just crash or continue to return semi-random results which may even happen to be correct (when the memory is not reused yet) Fix this by binding the temporary object (or initial object) to a const value reference which extents its lifetime and getting the `data_ptr` from that. Fixes pytorch#84748 This bug was introduced by a seemingly unrelated change in pytorch#64081 hence ccing @d1jang Pull Request resolved: pytorch#84750 Approved by: https://github.com/kimishpatel
- Loading branch information