Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir] Fix a use after free when loading dependent dialects
The way dependent dialects are implemented is by recursively calling loadDialect in the constructor. This means we have to reload from the dialect table because the constructor might have rehashed that table. The steps for loading a dialect are 1. Insert a nullptr into loadedDialects. This indicates the dialect is loading 2. Call ctor(). This recursively loads dependent dialects 3. Insert the new dialect into the table. We had a conflict between steps 2 and 3 here. You have to be extremely unlucky though as rehashing is rare and operator[] does no generation checking on DenseMap. Changing that to an iterator would've uncovered this issue immediately.
- Loading branch information