Issue 126611
Summary [orcjit] Creating a orc::LLJIT on multiple threads fails with UNW_ENOMEM error on Darwin
Labels new issue
Assignees
Reporter 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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to