This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Change the order of members in MLIRContext to ensure dialects are destroyed first
ClosedPublic

Authored by laszlokindrat on May 25 2023, 6:28 AM.

Details

Summary

Currently, the dialects precede the registered operations in the context object, which means that the latter is destroyed first. At the same time, Operation::~Operation dereferences the registered operation when destroying properties, which can cause use-after-free (e.g. if a dialect owns an op). This patch fixes that by changing the order of the members so that dialects come after registered operations.

Diff Detail

Event Timeline

laszlokindrat created this revision.May 25 2023, 6:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 6:28 AM
laszlokindrat requested review of this revision.May 25 2023, 6:28 AM
lattner accepted this revision.May 25 2023, 8:55 AM
lattner added a subscriber: lattner.

LG, thank you! Please add something to the comment above the loadedDialects field to indicate that it needs to be after the other operations for destruction order. Thanks!

This revision is now accepted and ready to land.May 25 2023, 8:55 AM
rriddle accepted this revision.May 25 2023, 9:05 AM

Add comment re destruction order.

laszlokindrat edited the summary of this revision. (Show Details)May 25 2023, 9:15 AM