b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

heap corruption_corruption detected_printf %c

电脑杂谈  发布时间:2017-05-25 15:07:44  来源:网络整理

heap corruptionheap corruption

In order to release memory, your program must track the pointer for the allocated block andpass it to thefree()function.If the pointer is stale, or if it doesn't point to the exact start of the allocated block,it may result in heap corruption.

A pointer is stale when it refers to a block of memory that's already been released.A duplicate request to free() involves passing free() astale pointer—there's no way to know whether this pointer refers to unallocated memory,or to memory that's been used to satisfy an allocation request in another part of the program.

Passing a stale pointer to free() may result in a fault in the allocator,or worse, it may release a block that's been used to satisfy another allocation request.If this happens,the code making the allocation request may compete with another section ofcode that subsequently allocated the same region of heap,resulting in corrupted data for one or both.

The most effective way to avoid this error is to NULL out pointers when the block is released,but this is uncommon, and difficult to do when pointers are aliased in any way.

printf %c_heap corruption_corruption detected

A second common source of errors is to attempt to release an interior pointer(i.e., one that's somewhere inside the allocated block rather than at the beginning).This isn't a legal operation, but it may occur when the pointer has been usedin conjunction with pointer arithmetic. The result of providing an interiorpointer is highly dependent on the allocator and is largely unpredictable, butit frequently results in a fault in the free() call.

A rarer source of errors is to pass an uninitialized pointer to free().If the uninitialized pointer is an automatic (stack) variable, it maypoint to a heap buffer, causing the types of coherency problems describedfor duplicate free() requests above. If the pointer contains some othernon-NULL value, it may cause a fault in the allocator.


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-49188-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...