BUG/MINOR: buffers/threads: always clear a buffer's head before releasing it

A small race exists in buffers with "show sess all". This one wants to show
some information grabbed from the buffer (especially in HTX mode). But the
thread owning this buffer might just be releasing its area, right after a
free() or munmap() call, resulting in a head that is not seen as empty yet
though the area was released. It may then be dereferenced by "show sess all"
causing a crash. Note that in practice it only happens in debug mode with
UAF enabled, but it's tricky enough to fix it right now.

This should be backported to stable versions which support threads and a
store barrier. It's worth noting that by performing the clearing first,
b_free() and b_drop() now become two exact equivalent.

(cherry picked from commit 3b091f80aa66d538ea65a1fd7e60acfb37c5421a)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/doc/internals/buffer-api.txt b/doc/internals/buffer-api.txt
index 13881f7..abb5e9f 100644
--- a/doc/internals/buffer-api.txt
+++ b/doc/internals/buffer-api.txt
@@ -568,10 +568,10 @@
                     |                  | even if some memory is available
 --------------------+------------------+---------------------------------------
 __b_drop            | buffer *buf      | releases <buf> which must be allocated
-                    | ret: void        |
+                    | ret: void        | and marks it empty
 --------------------+------------------+---------------------------------------
 b_drop              | buffer *buf      | releases <buf> only if it is allocated
-                    | ret: void        |
+                    | ret: void        | and marks it empty
 --------------------+------------------+---------------------------------------
 b_free              | buffer *buf      | releases <buf> only if it is allocated
                     | ret: void        | and marks it empty