[Lldb-commits] [PATCH] D122660: [lldb] Avoid duplicate vdso modules when opening core files

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 29 08:35:03 PDT 2022


labath created this revision.
labath added reviewers: mgorny, clayborg, JDevlieghere.
Herald added subscribers: pmatos, asb, sunfish, sbc100.
Herald added a project: All.
labath requested review of this revision.
Herald added a subscriber: aheejin.
Herald added a project: LLDB.

When opening core files (and also in some other situations) we could end
up with two vdso modules. This could happen because the vdso module is
very special, and over the years, we have accumulated various ways to
load it.

In D10800 <https://reviews.llvm.org/D10800>, we added one mechanism for loading it, which took the form of
a generic load-from-memory capability. Unfortunately loading an elf file
from memory is not possible (because the loader never loads the entire
file), and our attempts to do so were causing crashes. So, in D34352 <https://reviews.llvm.org/D34352>, we
partially reverted D10800 <https://reviews.llvm.org/D10800> and implemented a custom mechanism specific to
the vdso.

Unfortunately, enough of D10800 <https://reviews.llvm.org/D10800> remained such that, under the right
circumstances, it could end up loading a second (non-functional) copy of
the vdso module. This happened when the process plugin did not support
the extended MemoryRegionInfo query (added in D22219 <https://reviews.llvm.org/D22219>, to workaround a
different bug), which meant that the loader plugin was not able to
recognise that the linux-vdso.so.1 module (this is how the loader calls
it) is in fact the same as the [vdso] module (the name used in
/proc/$PID/maps) we loaded before. This typically happened in a core
file, as they don't store this kind of information.

This patch fixes the issue by completing the revert of D10800 <https://reviews.llvm.org/D10800> -- the
memory loading code is removed completely. It also reduces the scope of
the hackaround introduced in D22219 <https://reviews.llvm.org/D22219> -- it isn't completely sound and is
only relevant for fairly old (but still supported) versions of android.

I added the memory loading logic to the wasm dynamic loader, which has
since appeared and is relying on this feature (it even has a test). As
far as I can tell loading wasm modules from memory is possible and
reliable. MachO memory loading is not affected by this patch, as it uses
a completely different code path.

Since the scenarios/patches I described came without test cases, I have
created two new gdb-client tests cases for them. They're not
particularly readable, but right now, this is the best way we can
simulate the behavior (bugs) of a particular dynamic linker.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122660

Files:
  lldb/include/lldb/Target/DynamicLoader.h
  lldb/packages/Python/lldbsuite/test/gdbclientutils.py
  lldb/source/Core/DynamicLoader.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h
  lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
  lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
  lldb/test/API/functionalities/gdb_remote_client/module_load.yaml

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122660.418889.patch
Type: text/x-patch
Size: 18179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220329/80cd2b62/attachment-0001.bin>


More information about the lldb-commits mailing list