Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XLA:Python] Fix more bugs in the weakref_lru_cache implementation. #17866

Merged
merged 1 commit into from
Oct 2, 2024

Commits on Oct 2, 2024

  1. [XLA:Python] Fix more bugs in the weakref_lru_cache implementation.

    a) MSVC's std::unordered_map says behavior is undefined if the hash function throws an exception (https://learn.microsoft.com/en-us/cpp/standard-library/unordered-map-class?view=msvc-170#emplace). That's easy to work around, though: we can just precompute all the hash functions.
    b) my idiom for avoiding heterogenous lookups had a use after free problem: the weakref callback is called after the object is already in an invalid state. However, there's a much simpler solution: just create the weakref object and use it as a key unconditionally. Yes, this will mean we create more weak references than perhaps we had to otherwise. But this is simple and obviously correct.
    
    PiperOrigin-RevId: 681522048
    hawkinsp authored and Google-ML-Automation committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    cd6e808 View commit details
    Browse the repository at this point in the history