Skip to content

[orcjit] Creating a orc::LLJIT on multiple threads fails with UNW_ENOMEM error on Darwin #126611

@cianciosa

Description

@cianciosa

I have a situation where I'm trying to create JIT c++ code from multiple independent threads.

Minimum test case:

#include <iostream>
#include <thread>
#include <vector>

#include "llvm/Support/TargetSelect.h"
#include "llvm/ExecutionEngine/Orc/LLJIT.h"

int main(int argc, const char * argv[]) {
    std::vector<std::thread> threads(std::thread::hardware_concurrency());
    for (size_t i = 0, ie = threads.size(); i < ie; i++) {
        threads[i] = std::thread([] (const size_t thread_number) -> void {

            llvm::InitializeNativeTarget();
            llvm::InitializeNativeTargetAsmPrinter();

            auto jit_try = llvm::orc::LLJITBuilder().create();
            if (auto jiterror = jit_try.takeError()) {
                std::cerr << toString(std::move(jiterror)) << std::endl;
                exit(-1);
            }

        }, i);
    }
    for (std::thread &t : threads) {
        t.join();
    }
}

When running the above code, I get an error reported from multiple threads

Could not register function via __unw_add_find_dynamic_unwind_sections, error code = -6541

It appears this broke some time during the week starting on February 3rd but I have not been able to narrow it down to a specific commit. I have only checked this on macOS 15 and 14. Additionally llvm was built from top of tree main branch.

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