https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/183197
When ObjectFileWasm is passed a VirtualDataExtractor, it can have gaps between valid bytes in the DataBuffer. When we pass it to ValidateModuleHeader, we convert it to an ArrayRef (and later a StringRef) which crashes when we're trying to read across those gaps. rdar://171106338 >From 504340075953ff806f6a178002f7c8047a5fc4ee Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere <[email protected]> Date: Tue, 24 Feb 2026 14:55:56 -0800 Subject: [PATCH] [lldb] Fix crash in ObjectFileWasm when using a VirtualDataExtractor When ObjectFileWasm is passed a VirtualDataExtractor, it can have gaps between valid bytes in the DataBuffer. When we pass it to ValidateModuleHeader, we convert it to an ArrayRef (and later a StringRef) which crashes when we're trying to read across those gaps. rdar://171106338 --- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp index 2ecb60fe5cdca..7b150dd3e1935 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp @@ -157,8 +157,11 @@ ObjectFile *ObjectFileWasm::CreateInstance(const ModuleSP &module_sp, data_offset = 0; } - assert(extractor_sp); - if (!ValidateModuleHeader(extractor_sp->GetData())) { + // If this is operating on a VirtualDataExtractor, it can have gaps between + // valid bytes in the DataBuffer, so only get the contiguous part. + assert(extractor_sp && extractor_sp->GetContiguousDataExtractorSP()); + if (!ValidateModuleHeader( + extractor_sp->GetContiguousDataExtractorSP()->GetData())) { LLDB_LOGF(log, "Failed to create ObjectFileWasm instance: invalid Wasm header"); return nullptr; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
