See context in bazelbuild/bazel#20743
TL;DR: when running a grpc server inside macOS sandbox with internet access blocked, grpc sometimes failed to bind ipv6 localhost with the following error:
ci@bk-macstudio-9 sandbox_grpc_bug % /usr/bin/sandbox-exec -f no-internet.sb /Users/ci/workdir-pcloudy/bazel/bazel-bin/src/test/shell/bazel/bind
Exception in thread "main" java.io.IOException: Failed to bind to address /0:0:0:0:0:0:0:1:0
at io.grpc.netty.NettyServer.start(NettyServer.java:328)
at io.grpc.internal.ServerImpl.start(ServerImpl.java:185)
at io.grpc.internal.ServerImpl.start(ServerImpl.java:94)
at SocketBindingExample.main(SocketBindingExample.java:23)
Caused by: java.net.SocketException: Operation not permitted
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:459)
at java.base/sun.nio.ch.Net.bind(Net.java:448)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
What version of gRPC-Java are you using?
At least all versions from 1.49.x to 1.56.x
What is your environment?
macOS
What did you expect to see?
grpc successfully binding to ipv6 localhost inside macOS sandbox-exec
What did you see instead?
grpc sometimes failed to bind to ipv6 localhost inside macOS sandbox-exec
Steps to reproduce the bug
This issue is only reproducible on some of the Bazel CI mac machines, we are still not sure what specific environment triggered it. bazelbuild/bazel#20743 (comment) is the minimal reproducible case.
See context in bazelbuild/bazel#20743
TL;DR: when running a grpc server inside macOS sandbox with internet access blocked, grpc sometimes failed to bind ipv6 localhost with the following error:
What version of gRPC-Java are you using?
At least all versions from 1.49.x to 1.56.x
What is your environment?
macOS
What did you expect to see?
grpc successfully binding to ipv6 localhost inside macOS sandbox-exec
What did you see instead?
grpc sometimes failed to bind to ipv6 localhost inside macOS sandbox-exec
Steps to reproduce the bug
This issue is only reproducible on some of the Bazel CI mac machines, we are still not sure what specific environment triggered it. bazelbuild/bazel#20743 (comment) is the minimal reproducible case.