This is an archive of the discontinued LLVM Phabricator instance.

Plug errno in TCPSocket::Connect()
AbandonedPublic

Authored by krytarowski on Feb 23 2018, 2:48 PM.

Details

Reviewers
labath
joerg
Summary

Reset errno to 0 for error branches.

Without this, debugging real issues in LLDB is harder
as we don't know what and when caused the errno
to be set.

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Feb 23 2018, 2:48 PM

This seems weird. I have never seen anyone resetting errno *after* a call. Wouldn't it be better to log strerror(errno) somewhere, or make sure that the Status object reflects the actual error?

Yeah, never seen that before. Are you sure CreateSocket is doing the right thing and checking for the correct return value? That is the only way I can see this causing issues.

This just helps debugging connectivity issues in other unrelated code-parts (I'm debugging why select(2) / recv(2) don't receive a packet of type qHostInfo).

Floating errno is annoying.

TCPSocket::Connect() has no bugs at least I'm not aware of them.

https://github.com/search?l=C&q=save_errno&ref=opensearch&type=Code

Here is an approach with save_errno, useful in libraries when we preserve errno for public functions in the API of a library as-is, and not leaking it from the internals to unrelated code.

Right now I don't volunteer to perform this for LLDB, but it would be nice to not propagate it.

Yes, but that's why we have the Error objects, so we don't have to do the errno save-restore dance.

If this is just a debugging aid, then maybe you should keep it as such (locally). There are plenty of places that will leave a stray errno around and I don't think we want to do this resetting on all of them.

krytarowski abandoned this revision.Feb 23 2018, 3:26 PM

This is considered to be a local patch.