본문 바로가기

Heap analysis

(42)
(glibc 2.23)check_malloced_chunk 해당 함수를 malloc함수에서 재할당할 청크의 주소를 반환하기 전에 호출된다 do_check_remalloced_chunk를 호출하고 청크에 PREV_INUSE비트가 설정되어 있는지 확인한다 /* Properties of nonrecycled chunks at the point they are malloced */ static void do_check_malloced_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T s) { /* same as recycled case ... */ do_check_remalloced_chunk (av, p, s); /* ... plus, must obey implementation invariant that prev_inuse is a..
House of force 보호되어 있는 글입니다.
(glibc 2.23) free 힙의 할당한 메모리를 해제할 때 사용되는 함수이다 전체 코드 아래 더보기 더보기 void __libc_free (void *mem) { mstate ar_ptr; mchunkptr p; /* chunk corresponding to mem */ void (*hook) (void *, const void *) = atomic_forced_read (__free_hook); if (__builtin_expect (hook != NULL, 0)) { (*hook)(mem, RETURN_ADDRESS (0)); return; } if (mem == 0) /* free(0) has no effect */ return; p = mem2chunk (mem); if (chunk_is_mmapped (p)) /* rel..
(glibc 2.23) do_check_free_chunk 전체 코드는 아래 더보기 더보기 /* Properties of free chunks */ static void do_check_free_chunk (mstate av, mchunkptr p) { INTERNAL_SIZE_T sz = p->size & ~(PREV_INUSE | NON_MAIN_ARENA); mchunkptr next = chunk_at_offset (p, sz); do_check_chunk (av, p); /* Chunk must claim to be free ... */ assert (!inuse (p)); assert (!chunk_is_mmapped (p)); /* Unless a special marker, must have OK fields */ if ((unsigned long..
fastbin 보호되어 있는 글입니다.
(glibc 2.23) do_check_chunk 전체 코드는 아래 더보기 더보기 /* Properties of all chunks */ static void do_check_chunk (mstate av, mchunkptr p) { unsigned long sz = chunksize (p); /* min and max possible addresses assuming contiguous allocation */ char *max_address = (char *) (av->top) + chunksize (av->top); char *min_address = max_address - av->system_mem; if (!chunk_is_mmapped (p)) { /* Has legal address ... */ if (p != av->top) { if (..
(glibc 2.23) do_check_inuse_chunk 전체 코드는 아래 더보기 더보기 /* Properties of inuse chunks */ static void do_check_inuse_chunk (mstate av, mchunkptr p) { mchunkptr next; do_check_chunk (av, p); if (chunk_is_mmapped (p)) return; /* mmapped chunks have no next/prev */ /* Check whether it claims to be in use ... */ assert (inuse (p)); next = next_chunk (p); /* ... and is surrounded by OK chunks. Since more things can be checked with free ch..
(glibc 2.23) check_remalloced_chunk 전체 코드는 아래 더보기 더보기 /* Properties of chunks recycled from fastbins */ static void do_check_remalloced_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T s) { INTERNAL_SIZE_T sz = p->size & ~(PREV_INUSE | NON_MAIN_ARENA); if (!chunk_is_mmapped (p)) { assert (av == arena_for_chunk (p)); if (chunk_non_main_arena (p)) assert (av != &main_arena); else assert (av == &main_arena); } do_check_inuse_chunk (av,..