free
Riepilogo Ordine Gratuito
(Nessun controllo è spiegato in questo riepilogo e alcuni casi sono stati omessi per brevità)
Se l'indirizzo è nullo, non fare nulla
Se il chunk è stato mappato, smapparlo e terminare
Chiama
_int_free
:Se possibile, aggiungi il chunk al tcache
Se possibile, aggiungi il chunk al fast bin
Chiama
_int_free_merge_chunk
per consolidare il chunk se necessario e aggiungerlo alla lista non ordinata
__libc_free
Free
chiama __libc_free
.
Se l'indirizzo passato è Null (0) non fare nulla.
Controlla il tag del puntatore
Se il chunk è
mappato
,smappalo
e bastaSe no, aggiungi il colore e chiama
_int_free
su di esso
_int_free tcache
Inizialmente cercherà di allocare questo chunk nel tcache correlato. Tuttavia, vengono eseguiti alcuni controlli in precedenza. Scorrerà tutti i chunk del tcache nello stesso indice del chunk liberato e:
Se ci sono più voci rispetto a
mp_.tcache_count
:free(): troppi chunk rilevati nel tcache
Se l'entry non è allineata:
free(): chunk non allineato rilevato nel tcache 2
se il chunk liberato era già stato liberato e è presente come chunk nel tcache:
free(): doppia liberazione rilevata nel tcache 2
Se tutto va bene, il chunk viene aggiunto al tcache e la funzione ritorna.
_int_free fast bin
Inizia controllando che la dimensione sia adatta per il fast bin e verifica se è possibile impostarla vicino al top chunk.
Successivamente, aggiungi il chunk liberato in cima al fast bin mentre esegui alcuni controlli:
Se la dimensione del chunk non è valida (troppo grande o piccola) scatena:
free(): invalid next size (fast)
Se il chunk aggiunto era già in cima al fast bin:
double free or corruption (fasttop)
Se la dimensione del chunk in cima ha una dimensione diversa dal chunk che stiamo aggiungendo:
invalid fastbin entry (free)
_int_free_merge_chunk
Questa funzione cercherà di unire il chunk P di DIMENSIONE byte con i suoi vicini. Mettere il chunk risultante nell'elenco dei bin non ordinati.
Alcuni controlli vengono eseguiti:
Se il chunk è il chunk superiore:
double free or corruption (top)
Se il chunk successivo è al di fuori dei limiti dell'arena:
double free or corruption (out)
Se il chunk non è contrassegnato come usato (nel
prev_inuse
del chunk successivo):double free or corruption (!prev)
Se il chunk successivo ha una dimensione troppo piccola o troppo grande:
free(): invalid next size (normal)
se il chunk precedente non è in uso, cercherà di consolidare. Ma, se il prev_size differisce dalla dimensione indicata nel chunk precedente:
corrupted size vs. prev_size while consolidating
Last updated