<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hello Pavel,</p>
<p><br>
</p>
<p>Thanks for the reply. Unfortunately I cannot share the core dump with you.</p>
<p><br>
</p>
<p>Yes, Rob has figured that LLDB does not find this shared library and that causes the problem. To understand what is going on here, I need to add one more detail that was missing from my original post: this is a cross-machine investigation. I.e. the core
dump collected on one machine (CentOs) was sent to another</p>
<p>(Ubuntu) where I tried to open it.</p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">LLDB open</span><span style="font-size: 12pt;">s the executable without paying attention that there is a core dump attached and tries to locate shared libraries. Apparently the ones that exist on my machine are not good, so
it then looks in the directory with the executable itself. There is no way to "</span><span style="font-size: 12pt;">set solib-search-path" as we do on GDB and force it to look somewhere else. After we dumped all the shared libraries in the folder with the
executable LLDB was able to open the dump. This is a bit inconvenient, but works as a workaround for now.</span></p>
<p><br>
</p>
<div id="Signature">
<p>Sent from <a href="http://aka.ms/weboutlook" id="LPNoLP">Outlook</a><br>
</p>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Pavel Labath <labath@google.com><br>
<b>Sent:</b> Friday, January 20, 2017 6:55 AM<br>
<b>To:</b> Eugene Birukov<br>
<b>Cc:</b> LLDB; rdorr@microsoft.com<br>
<b>Subject:</b> Re: [lldb-dev] LLDB 3.9 on Linux crashes when loading core dump</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hello Eugene,<br>
<br>
I have been aware of this problem for a while, but I haven't found a<br>
really good solution so far, partially due to lack of a good repro<br>
case -- I think your analysis has helped me with this, and I am<br>
finally starting to piece together the sequence of events leading to<br>
the crash. If you have a repro case you can send me, it would be even<br>
better.<br>
<br>
I don't really have an answer to your quesiton, but here are a couple<br>
of observations (the details might be a bit sketchy - it's been a long<br>
time since I looked at this):<br>
- reading the section headers from memory should be a fallback.<br>
Normally we try first to locate the file on disk and read data from<br>
there. This was mainly added for the vdso "module", as that is not<br>
really present on disk. One of the ways of fixing this crash could be<br>
to figure out why we are not finding the c++abi binary on disk.<br>
<br>
- we trust far too much the data we read from inferior memory. We<br>
should be much more careful when doing things based on "untrusted"<br>
data. Checking the memory maps as you suggest could be one idea.<br>
Another option I am considering is teaching ReadMemory to allocate<br>
data in (reasonably sized, say a couple of MB) chunks. Right now it<br>
allocates the full buffer without even trying to read the memory. If<br>
it instead tried to read data in smaller chunks it would error out due<br>
to failure to read inferior memory long before it gets a chance to<br>
exhaust own address space. (With a sufficiently large chunk, this<br>
should not affect performance of normal reads).<br>
<br>
hope that helps,<br>
pl<br>
<br>
<br>
<br>
On 19 January 2017 at 19:41, Eugene Birukov via lldb-dev<br>
<lldb-dev@lists.llvm.org> wrote:<br>
> Hi,<br>
><br>
><br>
> I have a Linux core dump that causes LLDB 3.9 on Linux crash. I would<br>
> greatly appreciate any advise how to deal with the problem or what else I<br>
> should look at.<br>
><br>
><br>
> The core dump was produced by GDB and GDB itself opens it without problems.<br>
><br>
><br>
> So, during loading the core we call<br>
> DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() which enumerates all the<br>
> modules and does some processing. In the course of actions, it calls the<br>
> ObjectFileELF::GetSectionHeaderInfo() for each module. This guy tries to<br>
> load section headers and read string table. Well, it gets some garbage in<br>
> the section header struct and tries to allocate 1.5TB memory which causes<br>
> operator new throw.<br>
><br>
><br>
> So, why we get garbage?<br>
><br>
><br>
> The module in question is libc++abi.so.1:<br>
><br>
><br>
> 521 ModuleSP module_sp = LoadModuleAtAddress(I->file_spec,<br>
> I->link_addr, I->base_addr, true);<br>
><br>
> (gdb) p I->file_spec<br>
><br>
> $95 = {<br>
><br>
> m_directory = {<br>
><br>
> m_string = 0x829a58 "... redacted ..."<br>
><br>
> },<br>
><br>
> m_filename = {<br>
><br>
> m_string = 0x7cc9e8 "libc++abi.so.1"<br>
><br>
> },<br>
><br>
> m_is_resolved = false,<br>
><br>
> m_syntax = lldb_private::FileSpec::ePathSyntaxPosix<br>
><br>
> }<br>
><br>
><br>
> The module header lives at address 0x7f699a270000 and looks OK. The section<br>
> headers are supposed to be at offset 2495600 == 0x261470<br>
><br>
><br>
> $96 = (const elf::ELFHeader &) @0x953a78: {<br>
><br>
> e_ident = "\177ELF\002\001\001\000\000\000\000\000\000\000\000",<br>
><br>
> e_entry = 33392,<br>
><br>
> e_phoff = 64,<br>
><br>
> e_shoff = 2495600,<br>
><br>
> e_flags = 0,<br>
><br>
> e_version = 1,<br>
><br>
> e_type = 3,<br>
><br>
> e_machine = 62,<br>
><br>
> e_ehsize = 64,<br>
><br>
> e_phentsize = 56,<br>
><br>
> e_phnum = 7,<br>
><br>
> e_shentsize = 64,<br>
><br>
> e_shnum = 38,<br>
><br>
> e_shstrndx = 35<br>
><br>
> }<br>
><br>
><br>
> LLDB tries to read the section headers from that address 0x7f699a270000 +<br>
> 0x261470 == 0x7F699A4D1470 without a second thought, but this number is a<br>
> lie. The /proc/<pid>/maps file shows it as belonging to something else:<br>
><br>
><br>
> 7f699a270000-7f699a2ba000 r-xp 00000000 fd:02 537796791<br>
> .../libc++abi.so.1<br>
> 7f699a2ba000-7f699a4b9000 ---p 0004a000 fd:02 537796791<br>
> .../libc++abi.so.1<br>
> 7f699a4b9000-7f699a4bb000 r--p 00049000 fd:02 537796791<br>
> .../libc++abi.so.1<br>
> 7f699a4bb000-7f699a4bc000 rw-p 0004b000 fd:02 537796791<br>
> .../libc++abi.so.1<br>
> 7f699a4bc000-7f699a520000 r-xp 00000000 fd:00 202587414<br>
> /usr/lib64/libssl.so.1.0.1e<br>
> 7f699a520000-7f699a71f000 ---p 00064000 fd:00 202587414<br>
> /usr/lib64/libssl.so.1.0.1e<br>
> 7f699a71f000-7f699a723000 r--p 00063000 fd:00 202587414<br>
> /usr/lib64/libssl.so.1.0.1e<br>
> 7f699a723000-7f699a72a000 rw-p 00067000 fd:00 202587414<br>
> /usr/lib64/libssl.so.1.0.1e<br>
><br>
> I.e. LLDB should verify the module boundaries and fall back to some other<br>
> plan if the memory is not there.<br>
><br>
><br>
> Now the question is - where would be the right place to do the fix?<br>
><br>
><br>
> Thanks,<br>
><br>
> Eugene<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> Sent from Outlook<br>
><br>
><br>
> _______________________________________________<br>
> lldb-dev mailing list<br>
> lldb-dev@lists.llvm.org<br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br>
><br>
</div>
</span></font></div>
</div>
</body>
</html>