Xcode - scribbles, protective edges and malloc protection

Can someone explain what these options do in Xcode?

  • Enable Scribble
  • Enable Protective Edges
  • Enable Guard Malloc

what is it and what do they do, and how useful are they for debugging / testing?

thank.

+42
ios iphone xcode macos
Mar 06 '12 at 19:18
source share
2 answers

From the documentation .

  • Enable Scribble. Fill the allocated memory with 0xAA and the freed memory with 0x55.
  • Include protective edges. Add protective pages before and after large distributions.
  • Enable Guard Malloc. Use libgmalloc to detect common memory problems such as buffer overflows and post-launch usage.

Scribble will make it pretty obvious that you are using the memory block after it is freed, overwriting any data that was previously in the memory block after free.
Protective edges and Guard Malloc will help you find memory overflows and (to some extent) use of aftercare, protecting memory blocks for reading and writing to make your program more explicit if the memory is used incorrectly.

+40
Mar 06 '12 at 19:25
source share

The โ€œdocumentationโ€ link above refers to Xcode as a whole, but more specifically RN-MallocOptions describes these (and other) parameters in detail.

Jim Kubitschek shows a good example in Debugging broken memory in Obj-C , including the important "How to include them in Xcode?" Question:

Open the Edit Scheme window and go to the Diagnostics tab. Youll want to enable "Enable Scribble" and "Malloc Stack" .... in short, "Enabled Scribble" will force the allocator to write 0xAA to the newly allocated memory and write 0x55 to the freed memory. Malloc Stack will record the distribution and free history of your memory.

If you read this far, you will probably be interested in Apple Technical Note TN2239 iOS Debugging Magic or Technical Note TN2124Mac OS X Debug Magic .

+3
Apr 26 '13 at 15:34
source share



All Articles