[PATCH] D150184: [ORC] Fix race-condition in RTDyldObjectLinkingLayer::onObjEmit.

Moritz Kroll via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 14:08:14 PDT 2023


mkroll added a comment.

Finally found some time to continue looking into this...
`ObjectLinkingLayer` doesn't have this problem because it uses this order in `ObjectLinkingLayerJITLinkContext`:

1. `ObjectLinkingLayer::notifyEmitted()`:
  - `ObjectLinkingLayer::Plugin::notifyEmitted()`
  - Add `FinalizedAlloc` to `Allocs`
2. `MaterializationResponsiblity::notifyEmitted()` (**note:** The `FinalizedAlloc` is not explicitly removed from `Allocs`, if this fails. I didn't check, whether this happens indirectly)

We use the JIT to compile and execute shader code on the CPU (we also have backends for GPU). The problem occurred, when a mesh with 3 mio triangles was displaced on ARM with 8 CPUs and the same (we fixed that) displacement shader code was compiled 300 times in parallel.

Our JIT is based on the BuildingAJIT tutorial, not emitting lazily, using the ConcurrentIRCompiler, searching for symbols in specific modules to avoid problems with duplicate names and using an own copy of DefaultMMapper to avoid a use-after-free problem in the SectionMemoryManager, when things happen in the wrong order during application shutdown. All modules are linked with one "runtime" BareJITDylib, which only consists of absolute symbols pointing to hand-picked runtime functions. We're currently still using LLVM 12, but good to know, that I will have to rewrite the JIT integration again as with every LLVM upgrade ^_^


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150184/new/

https://reviews.llvm.org/D150184



More information about the llvm-commits mailing list