Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

libcurl dealt with this a few months ago, and the sentiment is about the same: thread cancellation in glibc is hairy. The short summary (which I think is accurate) is that an hostname query via libnss ultimately had to read a config file, and glibc's `open` is a thead cancellation point, so if it's canceled, it'll won't free memory that was allocated before the `open`.

The write-up is on how they're dealing with it starts at https://eissing.org/icing/posts/pthread_cancel/.



Note that the situation with libcurl is very specific: lookup with libnss is only available as a synchronous call. All other syscalls they make can be done with async APIs, which can easily be cancelled without any of the trickery discussed here.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: