Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORC: ObjectLinkingLayer test asserts on Windows #395

Open
maleadt opened this issue Mar 14, 2024 · 3 comments
Open

ORC: ObjectLinkingLayer test asserts on Windows #395

maleadt opened this issue Mar 14, 2024 · 3 comments
Labels

Comments

@maleadt
Copy link
Owner

maleadt commented Mar 14, 2024

MWE:

using LLVM

ollc = LLVM.ObjectLinkingLayerCreator() do es, triple
    ObjectLinkingLayer(es)
end

GC.@preserve ollc begin
    builder = LLJITBuilder()
    linkinglayercreator!(builder, ollc)
    @dispose ts_ctx=ThreadSafeContext() lljit=LLJIT(builder) begin
        jd = JITDylib(lljit)

        ts_mod = ThreadSafeModule("jit")
        sym = "SomeFunctionOLL"

        # build the module
        ts_mod() do mod
            ft = LLVM.FunctionType(LLVM.VoidType())
            fn = LLVM.Function(mod, sym, ft)

            @dispose builder=IRBuilder() begin
                entry = BasicBlock(fn, "entry")
                position!(builder, entry)
                ret!(builder)
            end
            verify(mod)
        end

        add!(lljit, jd, ts_mod)
        lookup(lljit, sym)
    end
end
Assertion failed: (KV.second.getFlags() & ~JITSymbolFlags::Common) == (I->second & ~JITSymbolFlags::Common) && "Resolving symbol with incorrect flags", file /workspace/srcdir/llvm-project/llvm/lib/ExecutionEngine/Orc/Core.cpp, line 2921

[2360] signal 22: SIGABRT
in expression starting at C:\Users\Tim\Julia\pkg\LLVM\wip3.jl:7
crt_sig_handler at C:/Users/Tim/Julia/src/julia/src\signals-win.c:95
raise at C:\Windows\System32\msvcrt.dll (unknown line)
abort at C:\Windows\System32\msvcrt.dll (unknown line)
assert at C:\Windows\System32\msvcrt.dll (unknown line)
llvm::orc::ExecutionSession::OL_notifyResolved(llvm::orc::MaterializationResponsibility&, llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void>, llvm::detail::DenseMapPair<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol> > const&) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::RTDyldObjectLinkingLayer::onObjLoad(llvm::orc::MaterializationResponsibility&, llvm::object::ObjectFile const&, llvm::RuntimeDyld::MemoryManager&, llvm::RuntimeDyld::LoadedObjectInfo&, std::map<llvm::StringRef, llvm::JITEvaluatedSymbol, std::less<llvm::StringRef>, std::allocator<std::pair<llvm::StringRef const, llvm::JITEvaluatedSymbol> > >, std::set<llvm::StringRef, std::less<llvm::StringRef>, std::allocator<llvm::StringRef> >&) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::Error llvm::detail::UniqueFunctionBase<llvm::Error, llvm::object::ObjectFile const&, llvm::RuntimeDyld::LoadedObjectInfo&, std::map<llvm::StringRef, llvm::JITEvaluatedSymbol, std::less<llvm::StringRef>, std::allocator<std::pair<llvm::StringRef const, llvm::JITEvaluatedSymbol> > > >::CallImpl<llvm::orc::RTDyldObjectLinkingLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >)::$_0>(void*, llvm::object::ObjectFile const&, llvm::RuntimeDyld::LoadedObjectInfo&, std::map<llvm::StringRef, llvm::JITEvaluatedSymbol, std::less<llvm::StringRef>, std::allocator<std::pair<llvm::StringRef const, llvm::JITEvaluatedSymbol> > >&) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::jitLinkForORC(llvm::object::OwningBinary<llvm::object::ObjectFile>, llvm::RuntimeDyld::MemoryManager&, llvm::JITSymbolResolver&, bool, llvm::unique_function<llvm::Error (llvm::object::ObjectFile const&, llvm::RuntimeDyld::LoadedObjectInfo&, std::map<llvm::StringRef, llvm::JITEvaluatedSymbol, std::less<llvm::StringRef>, std::allocator<std::pair<llvm::StringRef const, llvm::JITEvaluatedSymbol> > >)>, llvm::unique_function<void (llvm::object::OwningBinary<llvm::object::ObjectFile>, std::unique_ptr<llvm::RuntimeDyld::LoadedObjectInfo, std::default_delete<llvm::RuntimeDyld::LoadedObjectInfo> >, llvm::Error)>) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::RTDyldObjectLinkingLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::ObjectTransformLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::IRCompileLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >, llvm::orc::ThreadSafeModule) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::IRTransformLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >, llvm::orc::ThreadSafeModule) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::IRTransformLayer::emit(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >, llvm::orc::ThreadSafeModule) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::BasicIRLayerMaterializationUnit::materialize(std::unique_ptr<llvm::orc::MaterializationResponsibility, std::default_delete<llvm::orc::MaterializationResponsibility> >) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::MaterializationTask::run() at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
void llvm::detail::UniqueFunctionBase<void, std::unique_ptr<llvm::orc::Task, std::default_delete<llvm::orc::Task> > >::CallImpl<void (*)(std::unique_ptr<llvm::orc::Task, std::default_delete<llvm::orc::Task> >)>(void*, std::unique_ptr<llvm::orc::Task, std::default_delete<llvm::orc::Task> >&) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::ExecutionSession::dispatchOutstandingMUs() at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::ExecutionSession::OL_completeLookup(std::unique_ptr<llvm::orc::InProgressLookupState, std::default_delete<llvm::orc::InProgressLookupState> >, std::shared_ptr<llvm::orc::AsynchronousSymbolQuery>, std::function<void (llvm::DenseMap<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> >, llvm::DenseMapInfo<llvm::orc::JITDylib*, void>, llvm::detail::DenseMapPair<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> > > > const&)>) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::InProgressFullLookupState::complete(std::unique_ptr<llvm::orc::InProgressLookupState, std::default_delete<llvm::orc::InProgressLookupState> >) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::ExecutionSession::OL_applyQueryPhase1(std::unique_ptr<llvm::orc::InProgressLookupState, std::default_delete<llvm::orc::InProgressLookupState> >, llvm::Error) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::ExecutionSession::lookup(llvm::orc::LookupKind, std::vector<std::pair<llvm::orc::JITDylib*, llvm::orc::JITDylibLookupFlags>, std::allocator<std::pair<llvm::orc::JITDylib*, llvm::orc::JITDylibLookupFlags> > > const&, llvm::orc::SymbolLookupSet, llvm::orc::SymbolState, llvm::unique_function<void (llvm::Expected<llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void>, llvm::detail::DenseMapPair<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol> > >)>, std::function<void (llvm::DenseMap<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> >, llvm::DenseMapInfo<llvm::orc::JITDylib*, void>, llvm::detail::DenseMapPair<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> > > > const&)>) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::ExecutionSession::lookup(std::vector<std::pair<llvm::orc::JITDylib*, llvm::orc::JITDylibLookupFlags>, std::allocator<std::pair<llvm::orc::JITDylib*, llvm::orc::JITDylibLookupFlags> > > const&, llvm::orc::SymbolLookupSet, llvm::orc::LookupKind, llvm::orc::SymbolState, std::function<void (llvm::DenseMap<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> >, llvm::DenseMapInfo<llvm::orc::JITDylib*, void>, llvm::detail::DenseMapPair<llvm::orc::JITDylib*, llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr, void> > > > const&)>) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::ExecutionSession::lookup(std::vector<std::pair<llvm::orc::JITDylib*, llvm::orc::JITDylibLookupFlags>, std::allocator<std::pair<llvm::orc::JITDylib*, llvm::orc::JITDylibLookupFlags> > > const&, llvm::orc::SymbolStringPtr, llvm::orc::SymbolState) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::LLJIT::lookupLinkerMangled(llvm::orc::JITDylib&, llvm::orc::SymbolStringPtr) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
llvm::orc::LLJIT::lookupLinkerMangled(llvm::orc::JITDylib&, llvm::StringRef) at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
LLVMOrcLLJITLookup at C:\Users\Tim\Julia\src\julia\build\usr\bin\libLLVM-16jl.dll (unknown line)
LLVMOrcLLJITLookup at C:\Users\Tim\Julia\pkg\LLVM\lib\16\libLLVM.jl:4780
macro expansion at C:\Users\Tim\Julia\pkg\LLVM\src\executionengine\utils.jl:29 [inlined]
lookup at C:\Users\Tim\Julia\pkg\LLVM\src\orc.jl:228

I'm not very familar with the design of ORCv2, so pinging a couple of people who are: @vchuravy @gbaraldi. Our ORC integration does nothing with JIT symbol flags, but some tests do, e.g., what's added in #286 by @vchuravy.

@maleadt maleadt added the bug label Mar 14, 2024
@vchuravy
Copy link
Collaborator

@maleadt
Copy link
Owner Author

maleadt commented Mar 14, 2024

FWIW, that example compiles and executes without issues on the LLVM 16 toolchain used by Julia here.

@vchuravy
Copy link
Collaborator

We might be constructing a different TM, but otherwise things should be the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants