gpr_log sets errno to EINVAL on Fuchsia
- Dominant language
- C++
- Stars
- 45.3k
- Forks
- 11.4k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 47
Description
### What version of gRPC and what language are you using?
Version: https://github.com/grpc/grpc/tree/4ac9c6f755463a2321f84b0cb2d631e1828faedb
Language: C++
### What operating system (Linux, Windows,...) and version?
Fuchsia (latest)
### What runtime / compiler are you using (e.g. python version or version of gcc)
Compiling as part of Chromium from third_party/grpc/src.
### What did you do?
gpr_log is causing errno to set to EINVAL, which causes issues with tracing. If I enable tracing, then connecting to a socket fails in `src/core/lib/iomgr/tcp_client_posix.cc`, because the errno is modified between the `connect()` and when it is [compared](https://github.com/grpc/grpc/blob/master/src/core/lib/iomgr/tcp_client_posix.cc#L295).
I tested this theory with this small snippet of code
```
+ errno = 999;
+ gpr_log(GPR_ERROR, "errno=%d", errno); // prints errno=999
+ gpr_log(GPR_ERROR, "errno=%d", errno); // prints errno=22
```
### What did you expect to see?
I expected to see two log statements, both of which print 999.
Contributor guide
Assessment
This issue has not been assessed yet.