Mpatrol a Library for Controlling and Tracing Dynamic Memory Allocations Edition 2.13 for Mpatrol Version 1.4.8 8Th January, 2002

Total Page:16

File Type:pdf, Size:1020Kb

Mpatrol a Library for Controlling and Tracing Dynamic Memory Allocations Edition 2.13 for Mpatrol Version 1.4.8 8Th January, 2002 mpatrol A library for controlling and tracing dynamic memory allocations Edition 2.13 for mpatrol version 1.4.8 8th January, 2002 Graeme S. Roy Copyright c 1997-2002 Graeme S. Roy <[email protected]> Permission is granted to make and distribute verbatim copies of this manual provided the copy- right notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the condi- tions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. All product names mentioned in the documentation and source code for this library are the trademarks of their respective owners. i Table of Contents mpatrol ......................................... 1 Foreword ........................................ 3 1 Overview..................................... 5 2 Features ..................................... 7 3 Installation.................................. 13 4 Integration .................................. 15 4.1 Adding mpatrol ............................................ 15 4.2 Removing mpatrol.......................................... 17 5 Memory allocations .......................... 19 5.1 Static memory allocations ................................... 19 5.2 Stack memory allocations ................................... 19 5.3 Dynamic memory allocations ................................ 20 6 Operating system support.................... 21 6.1 Virtual memory ............................................ 21 6.2 Call stacks and symbol tables ............................... 22 6.3 Threads ................................................... 24 7 Using mpatrol ............................... 27 7.1 Library behaviour .......................................... 27 7.2 Logging and tracing ........................................ 28 7.3 General errors.............................................. 30 7.4 Overwrites and underwrites ................................. 30 7.5 Using with a debugger ...................................... 32 7.6 Testing .................................................... 36 7.7 Library functions ........................................... 37 7.8 Leak table ................................................. 45 8 Tools ....................................... 49 8.1 Dbmalloc-compatible functions .............................. 49 8.2 Dmalloc-compatible functions ............................... 50 8.3 Determining heap differences ................................ 51 8.4 Memory allocation gauge.................................... 51 8.5 Memory allocation tracing .................................. 51 ii mpatrol 9 Utilities ..................................... 53 9.1 The mpatrol command ..................................... 53 9.2 The mleak command ....................................... 55 9.3 The mpsym command ....................................... 55 9.4 The mpedit command ...................................... 56 9.5 The hexwords command .................................... 57 10 Profiling ................................... 59 11 Tracing .................................... 73 12 Heap corruption ............................ 81 13 Memory leaks .............................. 87 14 Improving performance ..................... 89 15 How it works............................... 93 16 Examples .................................. 95 16.1 Getting started............................................ 96 16.2 Detecting incorrect reuse of freed memory .................. 104 16.3 Detecting use of free memory.............................. 106 16.4 Using overflow buffers .................................... 109 16.5 Checking memory accesses ................................ 110 16.6 Bad memory operations................................... 111 16.7 Incompatible function calls................................ 112 16.8 The alloca() functions .................................. 113 16.9 The MP_MALLOC() functions ............................... 119 16.10 Additional useful information ............................ 121 17 Tutorial................................... 129 Appendix A Functions ........................ 137 A.1 C dynamic memory allocation functions .................... 137 A.2 C dynamic memory extension functions..................... 141 A.3 C dynamic memory alternative functions ................... 142 A.4 C++ dynamic memory allocation functions .................. 143 A.5 C memory operation functions ............................. 144 A.6 mpatrol library functions .................................. 146 Appendix B Environment ..................... 153 Appendix C Options ......................... 161 Appendix D Diagnostic messages .............. 167 Appendix E Library performance.............. 175 iii Appendix F File formats...................... 177 F.1 Profiling file format ....................................... 177 F.2 Tracing file format ........................................ 178 Appendix G Supported systems ............... 179 Appendix H Porting.......................... 185 Appendix I Notes ............................ 193 I.1 Notes for all platforms ..................................... 193 I.2 Notes for UNIX platforms .................................. 198 I.3 Notes for Amiga platforms ................................. 199 I.4 Notes for Windows platforms ............................... 200 I.5 Notes for Netware platforms ................................ 200 Appendix J Frequently asked questions ........ 203 J.1 Documentation............................................ 203 J.2 Building .................................................. 204 J.3 Linking ................................................... 206 J.4 Running .................................................. 207 J.5 Files ..................................................... 211 Appendix K Related software ................. 213 Appendix L References ....................... 233 Appendix M About the author ................ 235 Appendix N Copying ......................... 237 Function index ................................ 247 Index ......................................... 249 iv mpatrol mpatrol 1 mpatrol This document describes mpatrol, a library for controlling and tracing dynamic memory allocations. This is edition 2.13 of the mpatrol manual for version 1.4.8, 8th January, 2002. 2 mpatrol Foreword 3 Foreword I first started writing this library a few years ago when the company I work for sent me out to a customer who had reported a memory leak, which he expected was coming from the code generated by our C++ compiler. A few years on and the library has changed dramatically from its first beginnings, but I thought I'd release it publicly in case anyone else found it useful. When writing the library, I placed more emphasis on the quantity and quality of information about allocated memory rather than the speed and efficiency of allocating the actual memory. This means that the library will use dramatically more memory than normal dynamic memory allocation libraries and can slow down to a crawl depending on which options you use. However, the end results are likely to be accurate and reliable, and in most cases the library will run quite happily at a sane speed. The mpatrol library is by no means the only library of its kind. Solaris has no less that 6 different malloc libraries, and there are plenty available as freeware or as commercial products. Try to keep in mind that mpatrol comes with absolutely no warranty and so if it doesn't work for you and you need a fast solution, try some of the other libraries or products available. I have listed some of the most popular at the end of this manual (see Appendix K [Related software], page 213). This manual is arranged so that complete reference material on the mpatrol library can be found in the appendices, while introductory and background material can be found in the preceding chapters and sections. For readers who wish to delve right in and use the library, the Installation (see Chapter 3 [Installation], page 13) and Examples (see Chapter 16 [Examples], page 95) chapters should be enough to get started in combination with the quick reference card. Otherwise, this manual should be read from beginning to end in order to get the most out of the software it describes. Note that all of the output shown from the examples was produced on 32-bit environments, although mpatrol can be built to support 64-bit environments as well. Due to their very nature, problems with dynamic memory allocations are notoriously difficult to reproduce and debug, and this is likely to be the case if you find a bug in the mpatrol library as it might be extremely hard to reproduce on another system. Details on how to report bugs are given elsewhere in this document (see Appendix I [Notes], page 193), but it would be very useful if you could try to provide as much information as possible when reporting a problem, and that includes having a look in the library source code to see if it's obvious what is wrong. However, please try to read the frequently asked questions (see Appendix J [Frequently asked questions], page 203) first in case your question or problem is covered there since they are usually updated every time I receive a question about mpatrol. The latest version
Recommended publications
  • Samba Openldap: an Evolution and Insight
    IRACST – International Journal of Computer Networks and Wireless Communications (IJCNWC), ISSN: 2250-3501 Vol.2, No.3, June 2012 SAMBA OPENLDAP: AN EVOLUTION AND INSIGHT Ayodele Nojeem Lasisi Faculty of Information and Communication Technology Musibau Akintunde Ajagbe International Islamic University, P.O. Box 10, 50728 Faculty of Management and Human Resource Kuala Lumpur, Malaysia Development Universiti Teknologi Malaysia, 81310 Skudai Johor- Malaysia Abstract--Directory services facilitate access to information user authentication became more and more important. organized under a variety of frameworks and applications. The Access to web applications which is connected to LAN Lightweight Directory Access Protocol is a promising technology or single host will attract other parties which have no that provides access to directory information using a data access to the network and application to enter the structure similar to that of the X.500 protocol. IBM Tivoli, application. Therefore, mechanism to identify users Novell, Sun, Oracle, Microsoft, and many other vendor features LDAP-based implementations. The technology’s increasing which have privilege to access the application is needed. popularity is due both to its flexibility and its compatibility with However, in line with the growing number of web existing applications. A directory service is a searchable server applications, each application will need to database repository that lets authorized users and services find authenticate user or member. Therefore the user will information related to people, computers, network devices, and have a lot of username and pass word to remember, applications. Given the increasing need for information — this will complicate the user. For the simplification particularly over the Internet — directory popularity has grown purpose, the authentication method for user by using over the last decade and is now a common choice for distributed Lightweight Directory Access Protocol (LDAP) has applications.
    [Show full text]
  • BATCH PROCESSING of REMOTE SENSING JOBS on the PC Martin
    BATCH PROCESSING OF REMOTE SENSING JOBS ON THE PC Martin Ozga National Agricultural Statistics Service United States Department of Agriculture 3251 Old Lee Highway, Suite 305 Fairfax, VA 22030 [email protected] ABSTRACT The National Agricultural Statistics Service of the United States Department of Agriculture estimates crop acreage for entire states or major portions of states using satellite data, mostly Landsat 5 and Landsat 7. For the 1999 crop season, Landsat processing was done for Arkansas, Illinois, Mississippi, New Mexico, and North Dakota using more than 50 scene locations, many multitemporal. A system has been developed using mostly locally developed and some commercial software to do batch processing on Windows NT PCs. The main procedures which are implemented for batch processing are scene reformat, multitemporal scene creation, collection and grouping of ground truth pixels followed by supervised clustering, and maximum likelihood classification of entire scenes, generally multitemporal and using all bands. The user submits jobs using a GUI interface. The submission program checks that all required files are available and, if so, submits the job. There is one PC which is the batch server which acts as a central repository of batch jobs. The jobs are actually run on any Windows NT PC on the network which has been enabled to run batch jobs. This allows the use not only of dedicated batch PCs, but also other PCs during nights and weekends. INTRODUCTION The National Agricultural Statistics Service (NASS) of the United States Department of Agriculture (USDA) has long done crop acreage estimates based on areas known as segments from an area sampling frame.
    [Show full text]
  • XLNT V5 SP1 Reference Manual
    XLNT Reference Manual Version 5 Advanced Systems Concepts, Inc. Twelve Printing: November 2017 [V5.0 SP1] Eleventh Printing: July 2014 [V5.0] Tenth Printing: January 2006 [V4.0] Ninth Printing: April 2001 [V3.0] Eighth Printing: June 2000 [V2.0 SP4] Seventh Printing: September 1999 [V2.0 SP4] Sixth Printing: May 1999 [V2.0 SP3] Fifth Printing: February 1999 [V2.0 SP2] Fourth Printing: September 1998 [V2.0 SP1] Third Printing: May 1998 [V2.0] Second Printing: January 1998 (V1.1 (SP4)) First Printing: March 1997 (V1.1) The information in this document is subject to change without notice and should not be construed as a commitment by Advanced Systems Concepts, Inc. (ASCI). ASCI assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under license, and may only be used or copied in accordance with the terms of such license. The terms and conditions of license are furnished with the product in both hard copy as well as electronic form. ASCI logo and XLNT are registered trademarks of Advanced Systems Concepts, Inc. ASCI, XLNT logo are trademarks of Advanced Systems Concepts. Inc. Microsoft, Windows NT, ActiveX and Systems Management Server are trademarks of Microsoft Corporation. Copyright 1997-2017, Advanced Systems Concepts, Inc., Morristown, New Jersey, 07960, All Rights Reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording or by any information storage and retrieval system, without the written permission of Advanced Systems Concepts, Inc.
    [Show full text]
  • Activebatchtm User's Guide
    ActiveBatch User’s Guide Version 3 The Cross-Platform Enterprise Job Management and Scheduling System Advanced Systems Concepts, Inc. Sixth Edition: January 2002 Fifth Edition: August 2001 Fourth Edition: May 2001 Third Edition: April 2001 Second Printing: February 2001 First Printing: December 2000 The information in this document is subject to change without notice and should not be construed as a commitment by Advanced Systems Concepts, Inc. (ASCI). ASCI assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under license, and may only be used or copied in accordance with the terms of such license. The terms and conditions of the license are furnished with the product in both hard copy as well as electronic form. ASCI logo, ActiveBatch and XLNT are registered trademarks of Advanced Systems Concepts, Inc. ASCI, ActiveBatch logo, XLNT logo and BQMS are trademarks of Advanced Systems Concepts, Inc. Microsoft, Windows, Windows NT, ActiveX and Systems Management Server are trademarks of Microsoft Corporation. Other marks, as indicated, are owned by their respective companies. Copyright 1999-2002, Advanced Systems Concepts, Inc., Hoboken New Jersey, 07030 All Rights Reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording or by any information storage and retrieval system, without the written permission of Advanced Systems Concepts, Inc. Table of Contents 1 LICENSE AGREEMENTS
    [Show full text]
  • Remote Task Management in Embedded Devices
    Remote task management in embedded devices Master Thesis Study programme: N0714A150003 Mechatronics Author: Bc. Nikita Nagornov Thesis Supervisors: Ing. Jan Kraus, Ph.D. Institute of Mechatronics and Computer Engineering Thesis Consultant: Ing. Ekaterina Nyrobtseva Institute of Mechatronics and Computer Engineering Liberec 2020 Master Thesis Assignment Form Remote task management in embedded devices Name and surname: Bc. Nikita Nagornov Identification number: M19000212 Study programme: N0714A150003 Mechatronics Assigning department: Institute of Mechatronics and Computer Engineering Academic year: 2019/2020 Rules for Elaboration: 1. Study and analyse all requirements for a flexible task scheduler system with user friendly management of large number of tasks for data acquisition, processing and export in a multi-user environment. 2. Design the required infrastructure and develop your own application and its interfaces to allow simple handling of multiple automated tasks for a given embedded Linux environment. 3. Check the propper function of your application and evaluate its key performance indicators under real conditions. 4. Make a brief summary of your achievements in conclusion, discuss most important advantages and disadvantages of the presented solution and evaluate possibilities for its further improvements. Scope of Graphic Work: by appropriate documentation Scope of Report: 40–50 pages Thesis Form: printed/electronic Thesis Language: English List of Specialised Literature: [1] KELLER, Michael S. Take command: cron: Job scheduler. Linux Journal, 1999, 1999.65es: 15. [2] ENVIS Application User Guide: Version 1.8 for Supported Measuring Instruments [online]. Liberec: K M B systems, 2019 [cit. 2019-11-22]. [3] SAUTER, Thilo; LOBASHOV, Maksim. End-to-end communication architecture for smart grids. IEEE [4] Transactions on Industrial Electronics, 2011, 58.4: 1218-1228.
    [Show full text]
  • XLNT V5 Getting Started Guide
    What Do You Do After You See the Dollar Sign? A Getting Started Guide to the XLNT Language Advanced Systems Concepts, Inc. 1180 Headquarters Plaza West Tower, Third Floor Morristown, NJ 07960 United States Phone: +1-973-539-2660 Fax: +1-973 -539-3390 Web: www.advsyscon.com XLNT Getting Started Guide Fifth Printing: July 2014 Fourth Printing: November 2012 Third Printing: March 2006 Second Printing: May 2001 First Printing: September, 1997 The information in this document is subject to change without notice and should not be construed as a commitment by Advanced Systems Concepts, Inc. (ASCI). ASCI assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under license, and may only be used or copied in accordance with the terms of such license. The terms and conditions of license are furnished with the product in both hard copy as well as electronic form. ASCI logo and XLNT are registered trademarks of Advanced Systems Concepts, Inc. ASCI and XLNT logo are trademarks of Advanced Systems Concepts, Inc. All other trademarks and registered trademarks are the property of their respective holders. Copyright © 1997-2014 Advanced Systems Concepts, Inc., Morristown, New Jersey 07960, United States. All Rights Reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording or by any information storage and retrieval system, without the written permission of Advanced Systems Concepts, Inc. XLNT Getting Started Guide XLNT Getting Started Guide Welcome Welcome to XLNT! If you’ve followed the instructions to install and start the product, you should now be staring at an empty console window, on which is displayed a dollar sign ($).
    [Show full text]