llvm-c166/lldb/source/Target
Yao Qi 01bb84ce89
[lldb] Guard MemoryCache::ReadRanges against a short buffer (#218706)
`Process::DoReadMemoryRanges` asserts the caller's buffer is long enough
before it writes into it, and returns empty ranges when asserts are off.
`MemoryCache::ReadRanges` writes a cache hit into the same buffer with
no
such check, in `lldb/source/Target/Memory.cpp`:

```
316:      results.push_back(buffer.take_front(len));   // take_front clamps 16 -> 8
317:      buffer = buffer.drop_front(len);             // asks to drop 16 from 8
318:      memcpy(results.back().data(), cached, len);  // writes 16 into 8 bytes
```

With assertions on, `MutableArrayRef::drop_front` aborts one line before
the `memcpy`, so the new test dies on the wrong message:

```
Death test: { read_results = cache.ReadRanges(ranges, short_buffer); }
    Result: died but not with expected error.
  Expected: contains regular expression "MemoryCache::ReadRanges: provided buffer is too short"
Actual msg:
[  DEATH   ] Assertion failed: (this->size() >= N && "Dropping more elements than exist"), function drop_front, file ArrayRef.h, line 384.
```

With assertions off that abort is gone and the `memcpy` runs.  An
AddressSanitizer build reports a heap-buffer-overflow write of 16 bytes
into the 8 byte buffer, 8 bytes past its end.
`Process::ReadMemoryRanges` goes through the cache unless it is
disabled,
so the cache is the first of the two to write and it needs the same
guard.

`TestReadMemoryRangesWithShortBuffer` did not catch this because both of
its ranges miss the cache, which leaves the whole buffer to
`DoReadMemoryRanges` and lets that assert fire first.  Disable the cache
in it so it reaches the guard it is named after, and add a case whose
range hits the cache. Name the function in both assert messages: the old
message is a substring of the new one, and a death test matches by
substring, so naming only the new guard would leave that test accepting
either.
2026-08-26 12:30:13 +01:00
..
ABI.cpp Reapply "Make result variables obey their dynamic values in subsequent expressions" (#211321) (#213308) 2026-07-31 11:13:06 -07:00
AssertFrameRecognizer.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
BorrowedStackFrame.cpp
CMakeLists.txt [lldb] Wrap Target::GetAPIMutex() into a Lockable handle (NFC) (#212872) 2026-08-14 22:30:17 +00:00
CoreFileMemoryRanges.cpp
DynamicRegisterInfo.cpp [lldb] Convert uses of RegisterTypeFlags into RegisterType (#213886) 2026-08-06 11:02:50 +01:00
ExecutionContext.cpp [lldb] Wrap Target::GetAPIMutex() into a Lockable handle (NFC) (#212872) 2026-08-14 22:30:17 +00:00
InstrumentationRuntime.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
InstrumentationRuntimeStopInfo.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
JITLoader.cpp
JITLoaderList.cpp
Language.cpp
LanguageRuntime.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
Memory.cpp [lldb] Guard MemoryCache::ReadRanges against a short buffer (#218706) 2026-08-26 12:30:13 +01:00
MemoryHistory.cpp
MemoryRegionInfo.cpp
MemoryRegionInfoCache.cpp [lldb] Use std::map in MemoryRegionInfoCache (#206986) 2026-07-02 07:59:53 +01:00
MemoryTagMap.cpp
ModuleCache.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
OperatingSystem.cpp
PathMappingList.cpp [lldb][NFC] Remove unused overload for PathMappingList::FindIteratorForPath (#218481) 2026-08-24 13:10:13 -07:00
Platform.cpp [lldb] Replace ConstString in Platform::GetFullNameForDylib (#214874) 2026-08-10 11:30:34 -07:00
Process.cpp [lldb] Guard MemoryCache::ReadRanges against a short buffer (#218706) 2026-08-26 12:30:13 +01:00
ProcessIOHandler.cpp
ProcessTrace.cpp [lldb] Adopt ProcessAddress in the read memory APIs (NFC) (#214088) 2026-08-17 21:19:14 -05:00
Queue.cpp
QueueItem.cpp
QueueList.cpp
RegisterContext.cpp
RegisterContextUnwind.cpp [lldb] Allow generic operands in DWARF binary type check (#209641) 2026-07-14 22:15:26 +00:00
RegisterNumber.cpp
RemoteAwarePlatform.cpp
ScriptedThreadPlan.cpp [lldb] Fix incorrect formatv format strings in logging (#215024) 2026-08-10 10:36:36 -07:00
SectionLoadHistory.cpp
SectionLoadList.cpp [lldb] Fix incorrect formatv format strings in logging (#215024) 2026-08-10 10:36:36 -07:00
StackFrame.cpp
StackFrameList.cpp [lldb] Inherit behaves_like_zeroth_frame in synthesized inline frames (#217377) 2026-08-20 08:51:42 +01:00
StackFrameRecognizer.cpp [lldb/Interpreter] Surface Python exceptions from scripted extensions (#198153) 2026-07-31 17:51:12 -07:00
StackID.cpp [lldb][NFC] Create StackID::IsYounger (#209402) 2026-07-15 11:05:10 +00:00
Statistics.cpp Reapply "[lldb] Remove ConstString from FileSpec" (#211927) (#214599) 2026-08-07 11:00:14 -07:00
StopInfo.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
StructuredDataPlugin.cpp
SyntheticFrameProvider.cpp
SystemRuntime.cpp
Target.cpp [lldb] Preserve language order in Target::GetScratchTypeSystems (#217789) 2026-08-21 08:21:03 -07:00
TargetAPIMutex.cpp [lldb] Fix scripted frame provider cross-thread re-entrant deadlock (#208242) 2026-08-19 06:13:04 +00:00
TargetList.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
TargetProperties.td [lldb] Add target.jit-engine setting (#212998) 2026-07-31 09:06:36 +10:00
Thread.cpp [lldb] Remove ConstString from ThreadPlanStepInRange (#215684) 2026-08-12 11:20:21 -07:00
ThreadCollection.cpp
ThreadList.cpp
ThreadPlan.cpp
ThreadPlanBase.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanCallFunction.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanCallFunctionUsingABI.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanCallOnFunctionExit.cpp
ThreadPlanCallUserExpression.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanRunToAddress.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanShouldStopHere.cpp Don't ask trampoline handler plans to step past line 0. (#216770) 2026-08-17 11:11:14 -07:00
ThreadPlanSingleThreadTimeout.cpp
ThreadPlanStack.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanStepInRange.cpp Don't ask trampoline handler plans to step past line 0. (#216770) 2026-08-17 11:11:14 -07:00
ThreadPlanStepInstruction.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanStepOut.cpp Don't ask trampoline handler plans to step past line 0. (#216770) 2026-08-17 11:11:14 -07:00
ThreadPlanStepOverBreakpoint.cpp
ThreadPlanStepOverRange.cpp Don't ask trampoline handler plans to step past line 0. (#216770) 2026-08-17 11:11:14 -07:00
ThreadPlanStepRange.cpp [lldb][NFC] Create StackID::IsYounger (#209402) 2026-07-15 11:05:10 +00:00
ThreadPlanStepThrough.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanStepUntil.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadPlanTracer.cpp [lldb][NFC] Remove Stream::Printf calls with constant strings in Target/* (#210287) 2026-07-21 11:32:37 +01:00
ThreadSpec.cpp
Trace.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
TraceCursor.cpp
TraceDumper.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
TraceExporter.cpp
UnixSignals.cpp
UnwindAssembly.cpp
UnwindLLDB.cpp