
Linux Core Dump Analysis Dmitry Vostokov Software Diagnostics Services GDB Commands We use these boxes to Prerequisites introduce GDB commands used in practice exercises Basic Linux troubleshooting © 2015 Software Diagnostics Services Training Goals Review fundamentals Learn how to collect core dumps Learn how to analyze core dumps © 2015 Software Diagnostics Services Training Principles Talk only about what I can show Lots of pictures Lots of examples Original content © 2015 Software Diagnostics Services Schedule Summary Day 1 Analysis Fundamentals (30 minutes) Core dump collection methods (10 minutes) Basic Core Memory Dumps (1 hour 20 minutes) Day 2 Core Memory Dumps (2 hours) © 2015 Software Diagnostics Services Part 1: Fundamentals © 2015 Software Diagnostics Services Memory/Kernel/User Space Kernel Space 00007FFFFFFFFFFF User Space 0000000000010000 000000000000FFFF NULL Pointers 0000000000000000 © 2015 Software Diagnostics Services App/Process/Library Kernel Space 00007FFFFFFFFFFF ld.so libc.so ld.so User Space (PID 9200) libc.so App0 App0 0000000000010000 © 2015 Software Diagnostics Services Process Memory Dump GDB Commands info sharedlibrary Kernel Space Lists dynamic libraries maintenance info sections Lists memory regions 00007FFFFFFFFFFF ld.so libc.so User Space (PID 9200) core App0 0000000000010000 © 2015 Software Diagnostics Services Lightweight Processes (Threads) GDB Commands info threads Lists threads Kernel Space thread <n> Switches between threads thread apply all bt Lists stack traces from all threads LWP 9400 LWP 9401 ld.so libpthread.so libc.so User Space (PID 9400) App1 © 2015 Software Diagnostics Services Thread Stack Raw Data GDB Commands x/<n>a <address> Prints n addresses with Kernel Space corresponding symbol mappings if any LWP 9400 LWP 9401 Stack for LWP 9400 (TID) ld.so libpthread.so libc.so Stack for LWP 9401 (TID) User Space (PID 9400) App1 © 2015 Software Diagnostics Services Thread Stack Trace FunctionA() User Stack for LWP 10707 { GDB Commands ... FunctionB(); ... (gdb) bt } #0 0x00007fe9676bf48d in FunctionD () #1 0x00007fe9676bf300 in FunctionC () FunctionB() { #2 0x00000000004005ca in FunctionB () Return address FunctionC+130 ... #3 0x00000000004005da in FunctionA () 0x00007fe9676bf300 FunctionC(); ... } FunctionC() Return address FunctionB+220 { 0x00000000004005ca ... FunctionD(); ... } FunctionA Resumes from address Saves return address FunctionA+110 FunctionA+110 Return address FunctionA+110 FunctionB 0x00000000004005da Resumes from address Saves return address FunctionB+220 FunctionB+220 FunctionC Resumes from address Saves return address FunctionC+130 FunctionC+130 FunctionD © 2015 Software Diagnostics Services GDB vs. WinDbg GDB Commands (gdb) bt #0 0x00007fe9676bf48d in FunctionD () #1 0x00007fe9676bf300 in FunctionC () #2 0x00000000004005ca in FunctionB () #3 0x00000000004005da in FunctionA () WinDbg Commands 0:000> kn 00 00007fe9676bf300 Module!FunctionD+offset 01 00000000004005ca Module!FunctionC+130 02 00000000004005da AppA!FunctionB+220 03 0000000000000000 AppA!FunctionA+110 © 2015 Software Diagnostics Services Thread Stack Trace (no symbols) User Stack for LWP 10707 Symbol file App.sym FunctionA 22000 - 23000 FunctionB 32000 - 33000 Return address FunctionC+130 0x00007fe9676bf300 Return address 0x00000000004005ca GDB Commands (gdb) bt #0 0x00007fe9676bf48d in FunctionD () #1 0x00007fe9676bf300 in FunctionC () #2 0x00000000004005ca in ?? () #3 0x00000000004005da in ?? () Return address 0x00000000004005da © 2015 Software Diagnostics Services Exceptions (Access Violation) Stack for LWP 3604 (TID) GDB Commands ld.so libpthread.so (gdb) x <address> 0x<address>: Cannot access MSignal 11 (segmentation fault) memory at address 0x<address> libc.so Stack for LWP 3605 (TID) User Space (PID 3604) App MNULL pointer 0x0 © 2015 Software Diagnostics Services Exceptions (Runtime) Stack for LWP 3714 (TID) ld.so libpthread.so libstdc++.so libc.so M Signal 6 (abort) Stack for LWP 3715 (TID) User Space (PID 3714) throws exception App © 2015 Software Diagnostics Services Pattern-Oriented Diagnostic Analysis Diagnostic Pattern: a common recurrent identifiable problem together with a set of recommendations and possible solutions to apply in a specific context. Diagnostic Problem: a set of indicators (symptoms, signs) describing a problem. Diagnostic Analysis Pattern: a common recurrent analysis technique and method of diagnostic pattern identification in a specific context. Diagnostics Pattern Language: common names of diagnostic and diagnostic analysis patterns. The same language for any operating system: Windows, Mac OS X, Linux, ... Problem Resolution Information Collection Information Extraction Problem Identification Troubleshooting (Scripts) (Checklists) (Patterns) Suggestions Debugging Strategy © 2015 Software Diagnostics Services Part 2: Core Dump Collection © 2015 Software Diagnostics Services Enabling Collection Temporary for the current user: $ ulimit -c unlimited Permanent for every user except root: Edit the file: /etc/security/limits.conf Add or uncomment the line: * soft core unlimited To limit root to 1GB add or uncomment this line: root hard core 1000000 © 2015 Software Diagnostics Services Generation Methods kill (requires ulimit): $ kill –s SIGQUIT PID $ kill –s SIGABRT PID gcore: $ gcore PID © 2015 Software Diagnostics Services Part 3: Practice Exercises © 2015 Software Diagnostics Services Links Memory Dumps: NOT IN THE PUBLIC PREVIEW VERSION Exercise Transcripts: NOT IN THE PUBLIC PREVIEW VERSION © 2015 Software Diagnostics Services Exercise 0 Goal: Install GDB and check if GDB loads a core dump correctly Patterns: Incorrect Stack Trace \ALCDA-Dumps\Exercise-A0.pdf © 2015 Software Diagnostics Services Process Core Dumps Exercises A1-A12 © 2015 Software Diagnostics Services Exercise A1 Goal: Learn how to list stack traces, disassemble functions, check their correctness, dump data, get environment Patterns: Manual Dump, Stack Trace, Stack Trace Collection, Annotated Disassembly, Paratext, Not My Version, Environment Hint \ALCDA-Dumps\Exercise-A1.pdf © 2015 Software Diagnostics Services Exercise A2D Goal: Learn how to identify exceptions, find problem threads and CPU instructions Patterns: NULL Pointer (data), Active Thread \ALCDA-Dumps\Exercise-A2D.pdf © 2015 Software Diagnostics Services Exercise A2C Goal: Learn how to identify exceptions, find problem threads and CPU instructions Patterns: NULL Pointer (code), Active Thread \ALCDA-Dumps\Exercise-A2C.pdf © 2015 Software Diagnostics Services Exercise A3 Goal: Learn how to identify spiking threads Patterns: Spiking Thread \ALCDA-Dumps\Exercise-A3.pdf © 2015 Software Diagnostics Services Exercise A4 Goal: Learn how to identify heap regions and heap corruption Patterns: Heap Corruption \ALCDA-Dumps\Exercise-A4.pdf © 2015 Software Diagnostics Services Exercise A5 Goal: Learn how to identify stack corruption Patterns: Local Buffer Overflow, Execution Residue \ALCDA-Dumps\Exercise-A5.pdf © 2015 Software Diagnostics Services Exercise A6 Goal: Learn how to identify stack overflow, stack boundaries, reconstruct stack trace Patterns: Stack Overflow, Execution Residue \ALCDA-Dumps\Exercise-A6.pdf © 2015 Software Diagnostics Services Exercise A7 Goal: Learn how to identify active threads Patterns: Divide by Zero, Active Thread \ALCDA-Dumps\Exercise-A7.pdf © 2015 Software Diagnostics Services Exercise A8 Goal: Learn how to identify runtime exceptions, past execution residue and stack traces, identify handled exceptions Patterns: C++ Exception, Execution Residue, Coincidental Symbolic Information, Handled Exception \ALCDA-Dumps\Exercise-A8.pdf © 2015 Software Diagnostics Services Exercise A9 Goal: Learn how to identify heap leaks Patterns: Heap Leak, Execution Residue, Module Hint \ALCDA-Dumps\Exercise-A9.pdf © 2015 Software Diagnostics Services Exercise A10 Goal: Learn how to identify heap contention wait chains, synchronization issues, advanced disassembly, dump arrays Patterns: Double Free, Heap Contention, Wait Chain, Critical Region, Self-Diagnosis \ALCDA-Dumps\Exercise-A10.pdf © 2015 Software Diagnostics Services Exercise A11 Goal: Learn how to identify synchronization wait chains, deadlocks, hidden and handled exceptions Patterns: Wait Chains, Deadlock, Execution Residue, Handled Exception \ALCDA-Dumps\Exercise-A11.pdf © 2015 Software Diagnostics Services Exercise A12 Goal: Learn how to dump memory for post-processing, get the list of functions and module variables, load symbols, inspect arguments and local variables Patterns: Module Variable \ALCDA-Dumps\Exercise-A12.pdf © 2015 Software Diagnostics Services Pattern Links (Linux and GDB) Active Thread Annotated Disassembly C++ Exception Coincidental Symbolic Information Critical Region Deadlock Divide by Zero Environment Hint Execution Residue Handled Exception Heap Contention Heap Corruption Heap Leak Lateral Damage Local Buffer Overflow Manual Dump Module Hint Module Variable Not My Version NULL Pointer (code) NULL Pointer (data) Paratext Self-Diagnosis Spiking Thread Stack Overflow Stack Trace Stack Trace Collection Wait Chain © 2015 Software Diagnostics Services Resources Software Diagnostics Institute Pattern-Driven Software Diagnostics Pattern-Based Software Diagnostics Debugging TV Rosetta Stone for Debuggers Accelerated Mac OS X Core Dump Analysis GDB Pocket Reference Memory Dump Analysis Anthology (some articles in volumes 1 and 7 cover GDB) Forthcoming volume 9 will have additional GDB articles © 2015 Software Diagnostics Services Q&A Please send your feedback using the contact form on PatternDiagnostics.com © 2015 Software Diagnostics Services Thank you for attendance! © 2015 Software Diagnostics Services .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages41 Page
-
File Size-