free
Resumen del Pedido Gratuito
(No se explican todas las comprobaciones en este resumen y algunos casos se han omitido por brevedad)
Si la dirección es nula, no hacer nada
Si el fragmento fue asignado con
mmap
, desasignarlo y finalizarLlamar a
_int_free
:Si es posible, agregar el fragmento al tcache
Si es posible, agregar el fragmento al fast bin
Llamar a
_int_free_merge_chunk
para consolidar el fragmento si es necesario y agregarlo a la lista no ordenada
__libc_free
Free
llama a __libc_free
.
Si la dirección pasada es Null (0), no hacer nada.
Comprobar la etiqueta del puntero
Si el fragmento está asignado con
mmap
, desasignarlo y eso es todoSi no, agregar el color y llamar a
_int_free
sobre él
_int_free tcache
Primero intentará asignar este fragmento en el tcache relacionado. Sin embargo, se realizan algunas comprobaciones previamente. Recorrerá todos los fragmentos del tcache en el mismo índice que el fragmento liberado y:
Si hay más entradas que
mp_.tcache_count
:free(): se detectaron demasiados fragmentos en el tcache
Si la entrada no está alineada:
free(): fragmento no alineado detectado en tcache 2
si el fragmento liberado ya fue liberado y está presente como fragmento en el tcache:
free(): doble liberación detectada en tcache 2
Si todo va bien, el fragmento se agrega al tcache y la función retorna.
_int_free_merge_chunk
Esta función intentará fusionar el fragmento P de SIZE bytes con sus vecinos. Coloca el fragmento resultante en la lista de fragmentos no ordenados.
Se realizan algunas comprobaciones:
Si el fragmento es el fragmento superior:
double free or corruption (top)
Si el siguiente fragmento está fuera de los límites del área de memoria:
double free or corruption (out)
Si el fragmento no está marcado como usado (en el
prev_inuse
del fragmento siguiente):double free or corruption (!prev)
Si el siguiente fragmento tiene un tamaño demasiado pequeño o demasiado grande:
free(): invalid next size (normal)
si el fragmento anterior no está en uso, intentará consolidar. Pero, si el prev_size difiere del tamaño indicado en el fragmento anterior:
corrupted size vs. prev_size while consolidating
Last updated