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

mimalloc: sync with upstream dev-slice branch #21548

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kleisauke
Copy link
Collaborator

Context: #20645.

Opened as draft, as this seems to cause an ICE due to use of __builtin_thread_pointer() within mimalloc.

static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept {
// Works on most Unix based platforms
return (uintptr_t)__builtin_thread_pointer();
}

Details
fatal error: error in backend: Cannot select: intrinsic %llvm.thread.pointer
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -fPIC -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/src/build/emcache/sysroot -D__EMSCRIPTEN_SHARED_MEMORY__=1 -D__EMSCRIPTEN_WASM_WORKERS__=1 -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -O2 -Wall -fno-unroll-loops -fno-builtin -Wno-deprecated-pragma -DEMMALLOC_NO_STD_EXPORTS -DMI_MALLOC_OVERRIDE -DMI_DEBUG=0 -g3 -Werror -DEMSCRIPTEN_DYNAMIC_LINKING -I/emsdk/upstream/emscripten/system/lib/mimalloc/include -pthread -matomics -mbulk-memory ../../../../../emsdk/upstream/emscripten/system/lib/mimalloc/src/init.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '../../../../../emsdk/upstream/emscripten/system/lib/mimalloc/src/init.c'.
4.	Running pass 'WebAssembly Instruction Selection' on function '@_mi_thread_id'
 #0 0x000056192db9ecd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/emsdk/upstream/bin/clang+0x2e5acd8)
 #1 0x000056192db9c1de llvm::sys::RunSignalHandlers() (/emsdk/upstream/bin/clang+0x2e581de)
 #2 0x000056192db9df2f llvm::sys::CleanupOnSignal(unsigned long) (/emsdk/upstream/bin/clang+0x2e59f2f)
 #3 0x000056192dafc38e (/emsdk/upstream/bin/clang+0x2db838e)
 #4 0x000056192dafc34b (/emsdk/upstream/bin/clang+0x2db834b)
 #5 0x000056192db98b7b (/emsdk/upstream/bin/clang+0x2e54b7b)
 #6 0x000056192c8ba3c3 (/emsdk/upstream/bin/clang+0x1b763c3)
 #7 0x000056192db008b0 llvm::report_fatal_error(llvm::Twine const&, bool) (/emsdk/upstream/bin/clang+0x2dbc8b0)
 #8 0x000056192eeb44ee llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/emsdk/upstream/bin/clang+0x41704ee)
 #9 0x000056192eeb398d (/emsdk/upstream/bin/clang+0x416f98d)
#10 0x000056192c947f25 (/emsdk/upstream/bin/clang+0x1c03f25)
#11 0x000056192eeaa37f llvm::SelectionDAGISel::DoInstructionSelection() (/emsdk/upstream/bin/clang+0x416637f)
#12 0x000056192eea9812 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/emsdk/upstream/bin/clang+0x4165812)
#13 0x000056192eea8771 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/emsdk/upstream/bin/clang+0x4164771)
#14 0x000056192eea569a llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/emsdk/upstream/bin/clang+0x416169a)
#15 0x000056192d0fd0f9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/emsdk/upstream/bin/clang+0x23b90f9)
#16 0x000056192d66a1c7 llvm::FPPassManager::runOnFunction(llvm::Function&) (/emsdk/upstream/bin/clang+0x29261c7)
#17 0x000056192d673ff3 llvm::FPPassManager::runOnModule(llvm::Module&) (/emsdk/upstream/bin/clang+0x292fff3)
#18 0x000056192d66af5d llvm::legacy::PassManagerImpl::run(llvm::Module&) (/emsdk/upstream/bin/clang+0x2926f5d)
#19 0x000056192e412eca clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__2::unique_ptr<llvm::raw_pwrite_stream, std::__2::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/emsdk/upstream/bin/clang+0x36ceeca)
#20 0x000056192e42c3d3 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/emsdk/upstream/bin/clang+0x36e83d3)
#21 0x000056192f8a5869 clang::ParseAST(clang::Sema&, bool, bool) (/emsdk/upstream/bin/clang+0x4b61869)
#22 0x000056192e8beae1 clang::FrontendAction::Execute() (/emsdk/upstream/bin/clang+0x3b7aae1)
#23 0x000056192e81a0a0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/emsdk/upstream/bin/clang+0x3ad60a0)
#24 0x000056192e9bf58a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/emsdk/upstream/bin/clang+0x3c7b58a)
#25 0x000056192c8b8d0f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/emsdk/upstream/bin/clang+0x1b74d0f)
#26 0x000056192c8b66c3 (/emsdk/upstream/bin/clang+0x1b726c3)
#27 0x000056192e67ec09 (/emsdk/upstream/bin/clang+0x393ac09)
#28 0x000056192dafc32c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/emsdk/upstream/bin/clang+0x2db832c)
#29 0x000056192e67e655 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__2::optional<llvm::StringRef>>, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>*, bool*) const (/emsdk/upstream/bin/clang+0x393a655)
#30 0x000056192e63c117 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/emsdk/upstream/bin/clang+0x38f8117)
#31 0x000056192e65c4ab clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__2::pair<int, clang::driver::Command const*>>&) (/emsdk/upstream/bin/clang+0x39184ab)
#32 0x000056192c8b5933 clang_main(int, char**, llvm::ToolContext const&) (/emsdk/upstream/bin/clang+0x1b71933)
#33 0x000056192c8c5a0a main (/emsdk/upstream/bin/clang+0x1b81a0a)
#34 0x00007ff19671ad90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x00007ff19671ae40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x000056192c82996a _start (/emsdk/upstream/bin/clang+0x1ae596a)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 34ba90745fa55777436a2429a51a3799c83c6d4c)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin
fatal error: error in backend: Cannot select: intrinsic %llvm.thread.pointer
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -fPIC -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/src/build/emcache/sysroot -D__EMSCRIPTEN_SHARED_MEMORY__=1 -D__EMSCRIPTEN_WASM_WORKERS__=1 -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -O2 -Wall -fno-unroll-loops -fno-builtin -Wno-deprecated-pragma -DEMMALLOC_NO_STD_EXPORTS -DMI_MALLOC_OVERRIDE -DMI_DEBUG=0 -g3 -Werror -DEMSCRIPTEN_DYNAMIC_LINKING -I/emsdk/upstream/emscripten/system/lib/mimalloc/include -pthread -matomics -mbulk-memory ../../../../../emsdk/upstream/emscripten/system/lib/mimalloc/src/alloc.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '../../../../../emsdk/upstream/emscripten/system/lib/mimalloc/src/alloc.c'.
4.	Running pass 'WebAssembly Instruction Selection' on function '@mi_free'
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/init-9e362e.c
clang: note: diagnostic msg: /tmp/init-9e362e.sh
clang: note: diagnostic msg: 

********************
 #0 0x0000555e3a8bccd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/emsdk/upstream/bin/clang+0x2e5acd8)
 #1 0x0000555e3a8ba1de llvm::sys::RunSignalHandlers() (/emsdk/upstream/bin/clang+0x2e581de)
 #2 0x0000555e3a8bbf2f llvm::sys::CleanupOnSignal(unsigned long) (/emsdk/upstream/bin/clang+0x2e59f2f)
 #3 0x0000555e3a81a38e (/emsdk/upstream/bin/clang+0x2db838e)
 #4 0x0000555e3a81a34b (/emsdk/upstream/bin/clang+0x2db834b)
 #5 0x0000555e3a8b6b7b (/emsdk/upstream/bin/clang+0x2e54b7b)
 #6 0x0000555e395d83c3 (/emsdk/upstream/bin/clang+0x1b763c3)
 #7 0x0000555e3a81e8b0 llvm::report_fatal_error(llvm::Twine const&, bool) (/emsdk/upstream/bin/clang+0x2dbc8b0)
 #8 0x0000555e3bbd24ee llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/emsdk/upstream/bin/clang+0x41704ee)
 #9 0x0000555e3bbd198d (/emsdk/upstream/bin/clang+0x416f98d)
#10 0x0000555e39665f25 (/emsdk/upstream/bin/clang+0x1c03f25)
#11 0x0000555e3bbc837f llvm::SelectionDAGISel::DoInstructionSelection() (/emsdk/upstream/bin/clang+0x416637f)
#12 0x0000555e3bbc7812 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/emsdk/upstream/bin/clang+0x4165812)
#13 0x0000555e3bbc6771 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/emsdk/upstream/bin/clang+0x4164771)
#14 0x0000555e3bbc369a llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/emsdk/upstream/bin/clang+0x416169a)
#15 0x0000555e39e1b0f9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/emsdk/upstream/bin/clang+0x23b90f9)
#16 0x0000555e3a3881c7 llvm::FPPassManager::runOnFunction(llvm::Function&) (/emsdk/upstream/bin/clang+0x29261c7)
#17 0x0000555e3a391ff3 llvm::FPPassManager::runOnModule(llvm::Module&) (/emsdk/upstream/bin/clang+0x292fff3)
#18 0x0000555e3a388f5d llvm::legacy::PassManagerImpl::run(llvm::Module&) (/emsdk/upstream/bin/clang+0x2926f5d)
#19 0x0000555e3b130eca clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__2::unique_ptr<llvm::raw_pwrite_stream, std::__2::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/emsdk/upstream/bin/clang+0x36ceeca)
#20 0x0000555e3b14a3d3 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/emsdk/upstream/bin/clang+0x36e83d3)
#21 0x0000555e3c5c3869 clang::ParseAST(clang::Sema&, bool, bool) (/emsdk/upstream/bin/clang+0x4b61869)
#22 0x0000555e3b5dcae1 clang::FrontendAction::Execute() (/emsdk/upstream/bin/clang+0x3b7aae1)
#23 0x0000555e3b5380a0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/emsdk/upstream/bin/clang+0x3ad60a0)
#24 0x0000555e3b6dd58a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/emsdk/upstream/bin/clang+0x3c7b58a)
#25 0x0000555e395d6d0f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/emsdk/upstream/bin/clang+0x1b74d0f)
#26 0x0000555e395d46c3 (/emsdk/upstream/bin/clang+0x1b726c3)
#27 0x0000555e3b39cc09 (/emsdk/upstream/bin/clang+0x393ac09)
#28 0x0000555e3a81a32c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/emsdk/upstream/bin/clang+0x2db832c)
#29 0x0000555e3b39c655 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__2::optional<llvm::StringRef>>, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>*, bool*) const (/emsdk/upstream/bin/clang+0x393a655)
#30 0x0000555e3b35a117 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/emsdk/upstream/bin/clang+0x38f8117)
#31 0x0000555e3b37a4ab clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__2::pair<int, clang::driver::Command const*>>&) (/emsdk/upstream/bin/clang+0x39184ab)
#32 0x0000555e395d3933 clang_main(int, char**, llvm::ToolContext const&) (/emsdk/upstream/bin/clang+0x1b71933)
#33 0x0000555e395e3a0a main (/emsdk/upstream/bin/clang+0x1b81a0a)
#34 0x00007fac0a394d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x00007fac0a394e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x0000555e3954796a _start (/emsdk/upstream/bin/clang+0x1ae596a)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 34ba90745fa55777436a2429a51a3799c83c6d4c)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/alloc-b491a5.c
clang: note: diagnostic msg: /tmp/alloc-b491a5.sh
clang: note: diagnostic msg: 

********************
em++: error: subprocess 3/16 failed (returned 1)! (cmdline: /emsdk/upstream/emscripten/emcc -c -O2 -Wall -fno-unroll-loops -fno-builtin -Wno-deprecated-pragma -DEMMALLOC_NO_STD_EXPORTS -DMI_MALLOC_OVERRIDE -DMI_DEBUG=0 -g -sSTRICT -Werror -sRELOCATABLE -DEMSCRIPTEN_DYNAMIC_LINKING -I/emsdk/upstream/emscripten/system/lib/mimalloc/include -pthread -sWASM_WORKERS ../../../../../emsdk/upstream/emscripten/system/lib/mimalloc/src/alloc.c)

@sbc100
Copy link
Collaborator

sbc100 commented Mar 18, 2024

Oh, I guess we should make __builtin_thread_pointer work. I've not seen that before.

@sbc100
Copy link
Collaborator

sbc100 commented Mar 18, 2024

Could you open an upsteam llvm issue regarding fatal error: error in backend: Cannot select: intrinsic %llvm.thread.pointer ?

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Should we wait until dev-slice lands in their main branch? I would guess that would be when they consider it stable, but I don't actually know their dev practices.

return ENOMEM;
}
return 0;
*addr = emmalloc_memalign(try_alignment, size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the emmalloc alignment limitations get fixed?

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

Successfully merging this pull request may close these issues.

None yet

3 participants