RIP pthread_cancel
9 hours ago
- #pthread_cancel
- #libcurl
- #DNS
- curl 8.16.0 introduced pthread_cancel to interrupt getaddrinfo() calls in threads, but it caused memory leaks.
- The issue arises when pthread_cancel interrupts getaddrinfo() during operations like reading /etc/gai.conf, leading to unreleased memory.
- glibc's design does not adequately prevent memory leaks during thread cancellation, making pthread_cancel unreliable for this use case.
- The curl team decided to remove pthread_cancel support due to the risk of repeated memory leaks in frequent operations.
- Applications can use c-ares for non-blocking DNS resolution as an alternative, though it lacks some glibc features.
- DNS operations remain complex and challenging to manage efficiently in libcurl.