https://bugs.openldap.org/show_bug.cgi?id=9210
--- Comment #3 from Howard Chu hyc@openldap.org --- (In reply to lukas.juhrich@agdsn.de from comment #2)
If you wish, I can try to reproduce this again. Unfortunately, this has been two months ago and I've only come around to the bugreporting now, so I will need to downgrade and set some things up again.
The basic observation still stands though, adding the errno fixes the symptom.
Yes, please try to reproduce it.
But you understand, the behavior you've reported is not how errno is documented to work. Your flamegraph shows that gnutls is underneath, perhaps it is mis-handling its reporting of success/failure. In any case, when an underlying call succeeds, its return value must be >= 0, and the value of errno is ignored. The value of errno is only significant if the return value is < 0.