llvm / llvm/llvm-project

Crash when JITDylib is closed while an archive member is being linked.

Open
#174,568 3 comments 0 reactions 2 assignees Claimed by @ItsGunjit View on GitHub
orcjit
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.