bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.46k stars 1.31k forks source link

lldb: address 0x0000000100000000 maps to more than one section #2127

Open ggreif opened 4 years ago

ggreif commented 4 years ago

Recently I have started to get strange warnings from wasmtime (HEAD) when running programs using lldb on Darwin. Below is a transcript.

../../llvm/bin/lldb -- target/debug/wasmtime -g sumsX.mo.wasm
(lldb) target create "target/debug/wasmtime"
Current executable set to '/Users/ggreif/motoko/wasmtime/target/debug/wasmtime' (x86_64).
(lldb) settings set -- target.run-args  "-g" "sumsX.mo.wasm"
(lldb) b spell
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) r
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000100000000 maps to more than one section: wasmtime.__TEXT and wasmtime.__TEXT
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000101636000 maps to more than one section: wasmtime.__DATA and wasmtime.__DATA
Process 73083 launched: '/Users/ggreif/motoko/wasmtime/target/debug/wasmtime' (x86_64)
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000100000000 maps to more than one section: wasmtime.__TEXT and wasmtime.__TEXT
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000101636000 maps to more than one section: wasmtime.__DATA and wasmtime.__DATA
Process 73083 exited with status = 0 (0x00000000) 
(lldb) r
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000100000000 maps to more than one section: wasmtime.__TEXT and wasmtime.__TEXT
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000101636000 maps to more than one section: wasmtime.__DATA and wasmtime.__DATA
Process 73151 launched: '/Users/ggreif/motoko/wasmtime/target/debug/wasmtime' (x86_64)
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000100000000 maps to more than one section: wasmtime.__TEXT and wasmtime.__TEXT
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000101636000 maps to more than one section: wasmtime.__DATA and wasmtime.__DATA
Process 73151 exited with status = 0 (0x00000000) 
(lldb) r
Process 73211 launched: '/Users/ggreif/motoko/wasmtime/target/debug/wasmtime' (x86_64)
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000100000000 maps to more than one section: wasmtime.__TEXT and wasmtime.__TEXT
warning: (x86_64) /Users/ggreif/motoko/wasmtime/target/debug/wasmtime(0x0000000100000000) address 0x0000000101636000 maps to more than one section: wasmtime.__DATA and wasmtime.__DATA
Process 73211 exited with status = 0 (0x00000000) 
(lldb) r
Process 73238 launched: '/Users/ggreif/motoko/wasmtime/target/debug/wasmtime' (x86_64)
1 location added to breakpoint 1
Process 73238 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000104728e51 JIT(0x108100000)`spell(dayX=(null)::tue) at sumsX.mo:36:5
   33   
   34   //func spell (day : Weekday) : Text =
   35   func spell (dayX : { #mon; #tue; #wed }) : Text =
-> 36       switch dayX {
   37           case (#mon) "Monday";
   38           case (#tue) "Tuesday";
   39           case _ "Weekend"
(lldb) 

As you can see, I needed several attempts until I could enter. I am attaching the sources. The lldb I use is derived from the rust-lang/llvm-project (branch 2020-05). The symptoms appear without setting a breakpoint also, so I don't think they are language specific.

ggreif commented 4 years ago

Artefacts: 2127.zip

ggreif commented 4 years ago

I tried reproduction with lldb-10.0.1 and it still happens.

The warning originates from lldb's SectionLoadList::SetSectionLoadAddress which carries a nice comment.

Here is the backtrace when triggered:

* thread #14, name = '<lldb.process.internal-state(pid=45835)>', stop reason = breakpoint 3.1
  * frame #0: 0x000000010136d81d liblldb.10.0.1.dylib`lldb_private::SectionLoadList::SetSectionLoadAddress(this=0x000000012921dfb0, section=std::__1::shared_ptr<lldb_private::Section>::element_type @ 0x000000013784e638 strong=3 weak=10, load_addr=4294967296, warn_multiple=true) at SectionLoadList.cpp:107:24
    frame #1: 0x0000000101369c53 liblldb.10.0.1.dylib`lldb_private::SectionLoadHistory::SetSectionLoadAddress(this=0x0000000119915fa0, stop_id=1, section_sp=std::__1::shared_ptr<lldb_private::Section>::element_type @ 0x000000013784e638 strong=3 weak=10, load_addr=4294967296, warn_multiple=true) at SectionLoadHistory.cpp:131:29
    frame #2: 0x00000001013db263 liblldb.10.0.1.dylib`lldb_private::Target::SetSectionLoadAddress(this=0x0000000119915c00, section_sp=std::__1::shared_ptr<lldb_private::Section>::element_type @ 0x000000013784e638 strong=3 weak=10, new_section_load_addr=4294967296, warn_multiple=true) at Target.cpp:2759:32
    frame #3: 0x00000001015ba2f1 liblldb.10.0.1.dylib`lldb_private::DynamicLoaderDarwin::UpdateImageLoadAddress(this=0x000000012921a4f0, module=0x000000013784df20, info=0x0000000118d1aea8) at DynamicLoaderDarwin.cpp:259:48
    frame #4: 0x00000001015bedd5 liblldb.10.0.1.dylib`lldb_private::DynamicLoaderDarwin::AddModulesUsingImageInfos(this=0x000000012921a4f0, image_infos=0x0000700008c24e48) at DynamicLoaderDarwin.cpp:669:11
    frame #5: 0x00000001015b53f8 liblldb.10.0.1.dylib`DynamicLoaderMacOS::DoInitialImageFetch(this=0x000000012921a4f0) at DynamicLoaderMacOS.cpp:180:7
    frame #6: 0x00000001015b7925 liblldb.10.0.1.dylib`lldb_private::DynamicLoaderDarwin::DidAttach(this=0x000000012921a4f0) at DynamicLoaderDarwin.cpp:70:3
    frame #7: 0x0000000101325c4a liblldb.10.0.1.dylib`lldb_private::Process::CompleteAttach(this=0x000000012acc4818) at Process.cpp:2924:11
    frame #8: 0x00000001013250e5 liblldb.10.0.1.dylib`lldb_private::Process::AttachCompletionHandler::PerformAction(this=0x0000000137b01b10, event_sp=std::__1::shared_ptr<lldb_private::Event>::element_type @ 0x00000001378015f0 strong=2 weak=1) at Process.cpp:2710:18
    frame #9: 0x0000000101322a8e liblldb.10.0.1.dylib`lldb_private::Process::HandlePrivateEvent(this=0x000000012acc4818, event_sp=std::__1::shared_ptr<lldb_private::Event>::element_type @ 0x00000001378015f0 strong=2 weak=1) at Process.cpp:3619:33