crash when running server on a used address

1,102 views
Skip to first unread message

Stefan Seefeld

unread,
Oct 31, 2018, 1:10:44 PM10/31/18
to grpc.io

Hello,

I'm using the C++ API to write an RPC server, following the provided example code:
```
  std::string server_address("0.0.0.0:50051");
  GreeterServiceImpl service;
  ServerBuilder builder;
  builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
  builder.RegisterService(&service);
  std::unique_ptr<Server> server(builder.BuildAndStart());
  server->Wait();
```

whenever another process is already using the above address, this code results in a segfault, with this error being printed out:

E1031 13:01:42.858837542   17537 server_chttp2.cc:40]        {"created":"@1541005302.858452834","description":"No address added out of total 1 resolved","file":"/home2/shenderson/GRPC/Google/grpc/git/grpc/src/core/ext/transport/chttp2/server/chttp2_server.cc","file_line":307,"referenced_errors":[{"created":"@1541005302.858443799","description":"Failed to add any wildcard listeners","file":"/home2/shenderson/GRPC/Google/grpc/git/grpc/src/core/lib/iomgr/tcp_server_posix.cc","file_line":324,"referenced_errors":[{"created":"@1541005302.858395680","description":"Unable to configure socket","fd":5,"file":"/home2/shenderson/GRPC/Google/grpc/git/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc","file_line":214,"referenced_errors":[{"created":"@1541005302.858378854","description":"OS Error","errno":98,"file":"/home2/shenderson/GRPC/Google/grpc/git/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc","file_line":187,"os_error":"Address already in use","syscall":"bind"}]},{"created":"@1541005302.858442040","description":"Unable to configure socket","fd":5,"file":"/home2/shenderson/GRPC/Google/grpc/git/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc","file_line":214,"referenced_errors":[{"created":"@1541005302.858431608","description":"OS Error","errno":98,"file":"/home2/shenderson/GRPC/Google/grpc/git/grpc/src/core/lib/iomgr/tcp_server_utils_posix_common.cc","file_line":187,"os_error":"Address already in use","syscall":"bind"}]}]}]}
Segmentation fault (core dumped)

I understand that the error stems from an unsuccessful socket bind. What I don't understand is whether I should check some error condition in my own code above, or whether it's the gRPC implementation that wrongly ignores this error internally, later causing the crash.

I'm running gRPC 1.14.0 (on Linux).

Is this a known issue ?

Thanks,
    Stefan

Eric Gribkoff

unread,
Nov 7, 2018, 1:36:47 PM11/7/18
to grpc.io

This question was also asked on github, so linking to the discussion for future searchers: https://github.com/grpc/grpc/issues/17075
Reply all
Reply to author
Forward
0 new messages