Author: labath Date: Thu Jun 14 07:41:30 2018 New Revision: 334717 URL: http://llvm.org/viewvc/llvm-project?rev=334717&view=rev Log: DebugNamesDWARFIndex: fix handling of compressed sections
This fixes a silly bug where we were accidentally freeing the memory used to store the decompressed .debug_names data. I had actually considered this scenario when writing the class and put appropriate precautions in place -- I just failed to wire it all up correctly. This was only an issue for compressed sections because in case of uncompressed ones we would access the data straight out of the mmapped object file. Added: lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Added: lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp?rev=334717&view=auto ============================================================================== --- lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp (added) +++ lldb/trunk/lit/SymbolFile/DWARF/debug-names-compressed.cpp Thu Jun 14 07:41:30 2018 @@ -0,0 +1,14 @@ +// Test for a bug where we crashed while processing a compressed debug_names +// section (use after free). + +// REQUIRES: lld, zlib + +// RUN: clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s +// RUN: ld.lld %t.o -o %t --compress-debug-sections=zlib +// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s + +// CHECK: Found 1 variables: +int foo; +// ONE-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = debug-names-compressed.cpp:[[@LINE-1]] + +extern "C" void _start() {} Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h?rev=334717&r1=334716&r2=334717&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Thu Jun 14 07:41:30 2018 @@ -53,6 +53,7 @@ private: DWARFDataExtractor debug_str_data, DWARFDebugInfo &debug_info) : DWARFIndex(module), m_debug_info(debug_info), + m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data), m_debug_names_up(std::move(debug_names_up)), m_fallback(module, &debug_info, GetUnits(*m_debug_names_up)) {} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits