[ORCJIT] Reinject contexts on first function lookup#655
Conversation
There was a problem hiding this comment.
Code Review
This pull request defers the initialization of library context symbols in the ORC JIT compiler to the first function lookup after an object file is added, rather than performing it immediately in the constructor. It also updates error handling in symbol resolution and adds corresponding tests. The reviewer feedback correctly identifies that the newly introduced state variable context_symbol_refreshed_ is accessed and modified concurrently without synchronization, which can lead to data races. Introducing a mutex to protect this state is highly recommended to ensure thread safety.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
f1c66ba to
c1c1484
Compare
Summary
If callers violate the AddObjectFile/GetFunction contract, LLVM may expose a newly added symbol and GetFunction may return its stable allocated address before that object's context slots are refreshed. The symbol remains visible, but context initialization is not guaranteed for that unsupported overlap.
Regression
One C object defines only __tvm_ffi__library_ctx and a probe. Barrier-synchronized first lookups verify that every returned function observes the injected pointer without adding another fixture.
Validation