ERR_REMOVE_STATE(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… ERR_REMOVE_STATE(3) β€” like, the whole page, bestie

okay so this one's from the Library Functions Manual and it's literally called ERR_REMOVE_STATE(3). it's giving "cleanup era" β€” we're freeing a thread's OpenSSL error queue. no cap. 🧹✨


🌸 NAME 🌸

ERR_remove_thread_state, ERR_remove_state β€” free a thread's OpenSSL error queue

like, the error queue belongs to a thread and we're setting it free. that's the whole vibe. 🫢


✨ SYNOPSIS ✨

first things first, you gotta be linked against the library β€œlibcrypto” and pull in the header:

#include <openssl/err.h>

then the main character:

void
ERR_remove_thread_state(const CRYPTO_THREADID *tid);

and then the Deprecated: one, she's retired but still hanging around:

void
ERR_remove_state(unsigned long pid);

πŸ¦‹ DESCRIPTION πŸ¦‹

so ERR_remove_thread_state() frees the error queue that's associated with thread tid. and if tid is NULL? the current thread gets its error queue removed. iconic behaviour, honestly. πŸ’…

here's the part you actually need to remember: error queue data structures are allocated automatically for new threads, which means they must be freed when threads are terminated β€” otherwise you get a memory leak. and leaks are not the vibe. 😭

bestie. fr fr. free your queues. the data structures don't free themselves.

now, ERR_remove_state() is deprecated and has been replaced by ERR_remove_thread_state(). and because threads in OpenSSL are no longer identified by unsigned long values, any argument you pass to this function is ignored. yep, ignored. deaded. irrelevant. so calling ERR_remove_state() is equivalent to calling ERR_remove_thread_state(NULL). same thing, different font. πŸŽ€


πŸ‘€ SEE ALSO πŸ‘€

go read that one next, iykyk. 🌈


⭐ HISTORY ⭐

ERR_remove_state() first appeared in SSLeay 0.6.1 and has been available since OpenBSD 2.4. she's been around a minute. πŸ‘‘

then it was deprecated in OpenSSL 1.0.0 and OpenBSD 4.9 β€” right when ERR_remove_thread_state() was introduced, and thread IDs were introduced to identify threads instead of unsigned long. glow-up era. πŸ¦‹βœ¨


and that's the page, bestie πŸ’– β€” brought to you by Debian, dated June 8, 2025, filed under ERR_REMOVE_STATE(3). go free those queues and slay. πŸŽ€πŸ’œ

πŸ“¦ where this page comes from