Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc sometimes failed to bind ipv6 localhost inside macOS sanbox-exec #10797

Closed
meteorcloudy opened this issue Jan 4, 2024 · 3 comments
Closed

Comments

@meteorcloudy
Copy link

meteorcloudy commented Jan 4, 2024

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.

@sergiitk
Copy link
Member

sergiitk commented Jan 9, 2024

This seems be caused by bazel, and got resolved in bazelbuild/bazel#20755.

EDIT: fixed the PR link.

@ejona86
Copy link
Member

ejona86 commented Jan 9, 2024

Seems this was never a gRPC issue and has been dealt with in bazel. Closing.

@ejona86 ejona86 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2024
@sergiitk
Copy link
Member

For posterity, after a reproduction attempt, I also responded here : bazelbuild/bazel#20743 (comment).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants