Crash when JITDylib is closed while an archive member is being linked.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
### Description:
If a JITDylib is closed while an archive member is in the process of being linked it may cause a crash.
### Root cause:
Closing the JITDylib destroys attached DefinitionGenerators. StaticLibraryDefinitionGenerator destruction destroys the `MemoryBuffer` for the archive. The in-flight link then accesses the freed memory, triggering a crash.
### Fix:
The `MemoryBuffer` for the archive member being linked needs to keep the archive buffer alive. We'll need to introduce a new `MemoryBuffer` derivative for this.
### Reproduction:
Difficult, as this depends on scheduling: the archive member must be in the process of being linked when some other thread causes the JITDylib to be closed (e.g. due to an error that will tear down the JIT).
Contributor guide
Assessment
This issue has not been assessed yet.