1 / 24

Purify – A tool to detect memory leaks and corruption

Purify – A tool to detect memory leaks and corruption. Presented By: Keyur Malaviya. Topics covered. Why Purify? What it can do? Features and benefits Purify vs Static Analysis Rational Purify for Windows How does it work? Type of Memory Errors Technique Source for this software

shiri
Download Presentation

Purify – A tool to detect memory leaks and corruption

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Purify – A tool to detect memory leaks and corruption Presented By: Keyur Malaviya

  2. Topics covered • Why Purify? • What it can do? • Features and benefits • Purify vs Static Analysis • Rational Purify for Windows • How does it work? • Type of Memory Errors • Technique • Source for this software • Support and issues • DEMO

  3. The Necessity PURIFY TOOL • Application behaviour: • Crashes intermittently • Uses too much memory • Runs too slowly • Isn’t well tested • Is about to ship • You need something • See what your code is really doing • Help spend less time finding bugs • Develop fast, reliable code

  4. PURIFY? • What is it? • What it can do for me? • How does it work? • How do I get it?

  5. Software Quality Management • IBM-Rational Products: • A set of runtime analysis tools • Increase code quality • Purify • Detecting Runtime Errors • Automatically pinpoints hard-to-find bugs • Profiling .NET Managed Code (Memory Profiling) • Quantify • Application profiler • Highlights performance bottlenecks • PureCoverage • Source code coverage analysis • Helps avoid shipping untested code

  6. Features and benefits • Who can use it? • For everybody • Unix, Windows, C, C++, Java, .NET • Developers and testers • Source Code required? • Monitors components with no source code • Interesting Features: • Rich command line interface and batch mode for automation • Integrations with Rational Robot, Rational ClearQuest, Rational ClearCase, and Microsoft Visual Studio.NET Current Version: PurifyPlus

  7. Product feature matrix

  8. What about static analysis tools • Static analysis tools are a great complement to Purify • Find errors that you don’t exercise in test cases • Find richer semantic errors, e.g. type safety • Find potential errors if calling patterns change • Analyze code sections before you have a working executable

  9. What about static analysis tools • Static analysis tools have limitations • Only find errors in the code you have source for • Not in libraries that you pass bad data too or that are buggy • Can miss errors whose cause & effect are distant in time & space • Or bury you in “possible” errors • Can take a long time to run

  10. Rational Purify for Windows • Java™, Visual C++ and all VS.NET managed languages (including C# and VB.NET) • Checks every component in your program • complex multi-threaded, multi-process applications • . DLL's, third party DLL's, Windows . DLL's • Microsoft Foundation Class Library and . DLL's • Visual C/C++ components embedded within Visual Basic • Applications, Internet Explorer, or any • Microsoft Office application • Microsoft Excel and Microsoft Word plug-ins • COM-enabled applications using OLE and ActiveX controls

  11. Requirements for Windows platform • Compilers: Microsoft Visual C++ 6.0, Microsoft Visual C++ .NET • Interpreters: Microsoft virtual machine for Java. Msjava.dll version >= 2828. Sun JVM 1.2.2 and higher. For Pentium 4 JDK 1.2.2, build 007 is required • Debuggers: Visual C++, WinDBG, NTSD • Debug formats:COFF, CV4 • Debug files:Debug data can be placed in .exe, .pdb, or .dbg files. Can also use .map files, if available

  12. Type of Memory Errors • ABR/ABW – Array bounds read/write • FMR/FMW – Freed memory read/write • UMR – Uninitialized memory read • MSE – Memory Segment Error • MLK – Memory Leak • NPR/NRW – Null Pointer Read • FMM – Freeing Mismatched Memory

  13. Purify limitations • Purify has problems detecting: • Array bound errors in static memory. • Array bound errors on the stack. • Improperly accessing legal memory (pointer manipulation).

  14. How does it work? • Take your compiled application apart • Find interesting places to insert probes • Put your application back together again • Run it and play • Detecting memory leaks • GC-like algorithm Maintain list of all allocated blocks in all heaps And call chain of allocator • On demand, scan memory for all in-scope pointers • Starting from anchors –stack, statics, registers • Any block not pointed to is “leaked”(MLK/PLK) All other blocks are “memory in use”(MIU)

  15. Technique • Track state of each byte in process address space -Red = logically unallocated to app -Yellow = allocated (malloc/new) but not written to yet (uninitialized) -Green = allocated and initialized • Add red guard zone to the ends of allocated blocks -To catch buffer overrun errors • Monitor every read and write instruction

  16. Purify’s memory state tracking

  17. Purify’s array bounds detection • Inserts guard zones around each block allocated. (Guard zones are colored red. A read or write to red memory triggers an array bounds violation) A read of yellow memory triggers ??? Uninitialized Read Violation

  18. Source for Purify • Download & install the Free 15 day trial http://www-128.ibm.com/developerworks/downloads/r/rpp/? S_TACT=105AGX14&S_CMP=DWNL • Apply the latest Fixpack/iFixto get the latest platform support http://www.ibm.com/products/finder/us/finders?pg=ddfinder& C1=5000583&C2=5000623&rcss=rtlprfypls • If you like it, buy it Rep: http://www-306.ibm.com/software/rational/howtobuy/contact/ Online: http://www.ibm.com/cgibin/software/track0.cgi?i=49435& c=69617&o=7&ef=T&cn=6137703

  19. Any Issues? • Yes! Many issues exists • Technical Support website • Online documentation and articles available to address such issues • developerWorks has several how-to articles and a Q&A Forum http://www128.ibm.com/developerworks/rational /products/purify • Web-based training course DEV205 http://www128.ibm.com/developerworks/rational/ library/4181.html

  20. QUESTION SO FAR?

  21. DEMO • ABR/W: Array Bounds Read/Write • ABWL: Late Detect Array Bounds Write (Error Detection) • Late detect scanafter every 200 heap operations or 10 seconds elapsed between heap operations • Notes: • Enable late detect scanning in the settings dialog boxes. • Do any one of the following: • Rerun the program using precise instrumentation. • Advanced tab -> settings lower the values for LDSC LDSI • settings -> Errors and Leaks tab -> Use Red zone length to increase the number of bytes Purify inserts

  22. BOX: MessageBox • Normally hidden by error filters. • Filter Manager ->View ->Global Filters • Purify Default Filters group and deselect the BOXfilter • BSR: Beyond stack read/write int* values() { int array[100]; … return array; } void caller() { int* arrPointer; arrPointer = values(); // arrPointer??? }

  23. EXC: Continued Exception • EXH: Handled Exception • EXI: Ignored Exception • EXU: Unhandled Exception • FFM: Freeing Freed Memory • FIM: Freeing Invalid Memory • FMM: Freeing Mismatched Memory • FMR/R: Free Memory Read/Write • FMWL: Late Detect Free Memory Write

  24. HAN: Invalid Handle • Instead of proper expected handle the value specified is not an active handle, or of the wrong type • Filter Manager ->View ->Global Filters • Purify Default Filters group and deselect the HAN filter • PAR: Bad Parameter

More Related