Skip to content

LLJIT::deinitialize not running static dtors in LLVM-17 #100500

@xybu

Description

@xybu

So I have a program that highly resembles the LLJITWithInitializers.cpp example except that we expose all symbols in process memory to JIT space.

Recently we're upgrading from LLVM-15 to LLVM-17 and found that our unit tests involving static dtors are broken. It appears that

  • static dtors in JITed module don't run anymore with LLJIT::deinitialize(JD)
  • Something generated by JIT is attached to the real __cxa_atexit() which causes segfault during shutdown.

Static ctors seem fine.
I was looking through the commits in Orc but too many to find something relevant.

Then I searched __cxa_atexit in the repo and found this comment about LocalCXXRuntimeOverrides in ExecutionUtils.h which seems to describe exactly what's happening. With LLJIT most details are sealed and we only call the clean interface.

I tried to do CXXRuntimeoverrides.enable(llJIT_->getMainJITDylib(), *mangle_) but got Duplicate definition of symbol '__dso_handle' for now. Still looking.

Platform is Linux x86_64.

I'm running out of ideas so wonder if any expert is aware of some changes to LLJIT that require users to do something different / explicit to handle static dtors or atexit() gracefully. Any help is super appreciated. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions